From bbd09a9093f47f1bed5e316f275c8ddb25869b0a Mon Sep 17 00:00:00 2001 From: fangyi Date: Mon, 26 May 2025 21:02:48 +0800 Subject: [PATCH] libvirt update to version 9.10.0-15 - cpu-Add-new-Dharma-CPU-model.patch - qemu-cvm-support-uefi-boot-by-rom.patch - iommufd-Support-configuring-iommufd-backends-for-qem.patch - vdpa-iommufd-Support-associating-iommufd-with-vDPA-h.patch - capabilities-add-fun-to-determine-if-binary-is-strat.patch - qemu_command-unsupport-command-line-will-not-built-f.patch - chardev-use-path-instead-of-fd-for-stratovirt.patch - Revert-qemu-command-Delegate-qemuBuildDriveStr-to-SD.patch - Revert-qemu-Remove-pre-blockdev-PFLASH-setup.patch - qemu_command-get-disk-alias-from-disk-instead-of-nod.patch Signed-off-by: fangyi --- ...emu-Remove-pre-blockdev-PFLASH-setup.patch | 143 +++++++++++++++++ ...and-Delegate-qemuBuildDriveStr-to-SD.patch | 50 ++++++ ...-fun-to-determine-if-binary-is-strat.patch | 46 ++++++ ...se-path-instead-of-fd-for-stratovirt.patch | 45 ++++++ cpu-Add-new-Dharma-CPU-model.patch | 131 +++++++++++++++ ...configuring-iommufd-backends-for-qem.patch | 151 ++++++++++++++++++ libvirt.spec | 24 ++- qemu-cvm-support-uefi-boot-by-rom.patch | 45 ++++++ ...-disk-alias-from-disk-instead-of-nod.patch | 84 ++++++++++ ...upport-command-line-will-not-built-f.patch | 72 +++++++++ ...port-associating-iommufd-with-vDPA-h.patch | 96 +++++++++++ 11 files changed, 886 insertions(+), 1 deletion(-) create mode 100644 Revert-qemu-Remove-pre-blockdev-PFLASH-setup.patch create mode 100644 Revert-qemu-command-Delegate-qemuBuildDriveStr-to-SD.patch create mode 100644 capabilities-add-fun-to-determine-if-binary-is-strat.patch create mode 100644 chardev-use-path-instead-of-fd-for-stratovirt.patch create mode 100644 cpu-Add-new-Dharma-CPU-model.patch create mode 100644 iommufd-Support-configuring-iommufd-backends-for-qem.patch create mode 100644 qemu-cvm-support-uefi-boot-by-rom.patch create mode 100644 qemu_command-get-disk-alias-from-disk-instead-of-nod.patch create mode 100644 qemu_command-unsupport-command-line-will-not-built-f.patch create mode 100644 vdpa-iommufd-Support-associating-iommufd-with-vDPA-h.patch diff --git a/Revert-qemu-Remove-pre-blockdev-PFLASH-setup.patch b/Revert-qemu-Remove-pre-blockdev-PFLASH-setup.patch new file mode 100644 index 0000000..0612779 --- /dev/null +++ b/Revert-qemu-Remove-pre-blockdev-PFLASH-setup.patch @@ -0,0 +1,143 @@ +From 37f3f0ef32ea47af956b8a6258e6071c76a05e24 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 26 May 2025 16:27:06 +0800 +Subject: [PATCH 8/9] Revert "qemu: Remove pre-blockdev PFLASH setup" + +Stratovirt doesn't support -blockdev cmd now. +So use -drive for qemu, use -blockdev for stratovirt. +This reverts commit e231bede440ff83404a11e3a414d2e6859d90c61. + +Signed-off-by: fangyi +--- + src/qemu/qemu_command.c | 60 ++++++++++++++++++++++++++++++++++------- + src/qemu/qemu_domain.c | 5 +++- + 2 files changed, 55 insertions(+), 10 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index bc84783335..9d701ed603 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -7076,7 +7076,8 @@ qemuBuildMachineCommandLine(virCommand *cmd, + } + } + +- if (virDomainDefHasOldStyleUEFI(def)) { ++ if (!virQEMUCapsHasStratovirt(qemuCaps) && ++ virDomainDefHasOldStyleUEFI(def)) { + if (priv->pflash0) + virBufferAsprintf(&buf, ",pflash0=%s", + qemuBlockStorageSourceGetEffectiveNodename(priv->pflash0)); +@@ -9536,10 +9537,53 @@ qemuBuildRedirdevCommandLine(virCommand *cmd, + } + + ++static void ++qemuBuildDomainLoaderPflashCommandLine(virCommand *cmd, ++ virDomainLoaderDef *loader, ++ virQEMUCaps *qemuCaps) ++{ ++ g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; ++ int unit = 0; ++ ++ if (loader->secure == VIR_TRISTATE_BOOL_YES) { ++ virCommandAddArgList(cmd, ++ "-global", ++ "driver=cfi.pflash01,property=secure,value=on", ++ NULL); ++ } ++ ++ /* with blockdev we instantiate the pflash when formatting -machine */ ++ if (!virQEMUCapsHasStratovirt(qemuCaps)) ++ return; ++ ++ virBufferAddLit(&buf, "file="); ++ virQEMUBuildBufferEscapeComma(&buf, loader->path); ++ virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit); ++ unit++; ++ ++ if (loader->readonly) { ++ virBufferAsprintf(&buf, ",readonly=%s", ++ virTristateSwitchTypeToString(loader->readonly)); ++ } ++ ++ virCommandAddArg(cmd, "-drive"); ++ virCommandAddArgBuffer(cmd, &buf); ++ ++ if (loader->nvram) { ++ virBufferAddLit(&buf, "file="); ++ virQEMUBuildBufferEscapeComma(&buf, loader->nvram->path); ++ virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit); ++ ++ virCommandAddArg(cmd, "-drive"); ++ virCommandAddArgBuffer(cmd, &buf); ++ } ++} ++ + + static void + qemuBuildDomainLoaderCommandLine(virCommand *cmd, +- virDomainDef *def) ++ virDomainDef *def, ++ virQEMUCaps *qemuCaps) + { + virDomainLoaderDef *loader = def->os.loader; + +@@ -9553,12 +9597,7 @@ qemuBuildDomainLoaderCommandLine(virCommand *cmd, + break; + + case VIR_DOMAIN_LOADER_TYPE_PFLASH: +- if (loader->secure == VIR_TRISTATE_BOOL_YES) { +- virCommandAddArgList(cmd, +- "-global", +- "driver=cfi.pflash01,property=secure,value=on", +- NULL); +- } ++ qemuBuildDomainLoaderPflashCommandLine(cmd, loader, qemuCaps); + break; + + case VIR_DOMAIN_LOADER_TYPE_NONE: +@@ -10035,6 +10074,9 @@ qemuBuildPflashBlockdevCommandLine(virCommand *cmd, + if (!virDomainDefHasOldStyleUEFI(vm->def)) + return 0; + ++ if (virQEMUCapsHasStratovirt(priv->qemuCaps)) ++ return 0; ++ + if (priv->pflash0 && + qemuBuildPflashBlockdevOne(cmd, priv->pflash0, priv->qemuCaps) < 0) + return -1; +@@ -10549,7 +10591,7 @@ qemuBuildCommandLine(virDomainObj *vm, + if (qemuBuildCpuCommandLine(cmd, driver, def, qemuCaps) < 0) + return NULL; + +- qemuBuildDomainLoaderCommandLine(cmd, def); ++ qemuBuildDomainLoaderCommandLine(cmd, def, qemuCaps); + + if (qemuBuildMemCommandLine(cmd, def, qemuCaps, priv) < 0) + return NULL; +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 020cfc8bff..715b0b91ca 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -11697,7 +11697,7 @@ qemuDomainSupportsCheckpointsBlockjobs(virDomainObj *vm) + * qemuDomainInitializePflashStorageSource: + * + * This helper converts the specification of the source of the 'loader' in case +- * PFLASH is required to virStorageSources. ++ * PFLASH is required to virStorageSources in case Stratovirt is present. + * + * This helper is used in the intermediate state when we don't support full + * backing chains for pflash drives in the XML. +@@ -11715,6 +11715,9 @@ qemuDomainInitializePflashStorageSource(virDomainObj *vm, + virDomainDef *def = vm->def; + g_autoptr(virStorageSource) pflash0 = NULL; + ++ if (virQEMUCapsHasStratovirt(priv->qemuCaps)) ++ return 0; ++ + if (!virDomainDefHasOldStyleUEFI(def)) + return 0; + +-- +2.45.2.windows.1 + diff --git a/Revert-qemu-command-Delegate-qemuBuildDriveStr-to-SD.patch b/Revert-qemu-command-Delegate-qemuBuildDriveStr-to-SD.patch new file mode 100644 index 0000000..b679385 --- /dev/null +++ b/Revert-qemu-command-Delegate-qemuBuildDriveStr-to-SD.patch @@ -0,0 +1,50 @@ +From 1d0fc65fe2233a3bccff24a0314fbd58e8bc12a3 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 26 May 2025 15:52:08 +0800 +Subject: [PATCH 7/9] Revert "qemu: command: Delegate qemuBuildDriveStr to SD + cards only" + +Stratovirt only supports legacy -drive cmd. +This reverts commit de538266a69e3f6bf927cadc5230f7dcf1c8a70f. + +Signed-off-by: fangyi +--- + src/qemu/qemu_command.c | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index a6a174228f..bc84783335 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -1693,7 +1693,17 @@ qemuBuildDriveStr(virDomainDiskDef *disk) + if (qemuBuildDriveSourceStr(disk, &opt) < 0) + return NULL; + +- virBufferAsprintf(&opt, "if=sd,index=%d", virDiskNameToIndex(disk->dst)); ++ if (!qemuDiskBusIsSD(disk->bus)) { ++ g_autofree char *drivealias = qemuAliasDiskDriveFromDisk(disk); ++ if (!drivealias) ++ return NULL; ++ ++ virBufferAddLit(&opt, "if=none"); ++ virBufferAsprintf(&opt, ",id=%s", drivealias); ++ } else { ++ virBufferAsprintf(&opt, "if=sd,index=%d", ++ virDiskNameToIndex(disk->dst)); ++ } + + if (disk->src->readonly) + virBufferAddLit(&opt, ",readonly=on"); +@@ -2177,7 +2187,8 @@ qemuBuildDiskSourceCommandLine(virCommand *cmd, + if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) { + if (!(data = qemuBuildStorageSourceChainAttachPrepareChardev(disk))) + return -1; +- } else if (!qemuDiskBusIsSD(disk->bus)) { ++ } else if (!virQEMUCapsHasStratovirt(qemuCaps) && ++ !qemuDiskBusIsSD(disk->bus)) { + if (virStorageSourceIsEmpty(disk->src)) + return 0; + +-- +2.45.2.windows.1 + diff --git a/capabilities-add-fun-to-determine-if-binary-is-strat.patch b/capabilities-add-fun-to-determine-if-binary-is-strat.patch new file mode 100644 index 0000000..aa4b1cf --- /dev/null +++ b/capabilities-add-fun-to-determine-if-binary-is-strat.patch @@ -0,0 +1,46 @@ +From 904c909de467fb3d60f0a6c27374a3386312b6e4 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Sat, 24 May 2025 17:27:40 +0800 +Subject: [PATCH 4/9] capabilities: add fun to determine if binary is + stratovirt + +This commit is in preparation for future support for stratovirt + +Signed-off-by: fangyi +--- + src/qemu/qemu_capabilities.c | 6 ++++++ + src/qemu/qemu_capabilities.h | 1 + + 2 files changed, 7 insertions(+) + +diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c +index 79414becfd..86f1491bc5 100644 +--- a/src/qemu/qemu_capabilities.c ++++ b/src/qemu/qemu_capabilities.c +@@ -2120,6 +2120,12 @@ const char *virQEMUCapsGetPackage(virQEMUCaps *qemuCaps) + } + + ++bool virQEMUCapsHasStratovirt(virQEMUCaps *qemuCaps) ++{ ++ return !!strstr(qemuCaps->package, "StratoVirt"); ++} ++ ++ + bool virQEMUCapsGetKVMSupportsSecureGuest(virQEMUCaps *qemuCaps) + { + return qemuCaps->kvmSupportsSecureGuest; +diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h +index 959fbe6378..a928f5947d 100644 +--- a/src/qemu/qemu_capabilities.h ++++ b/src/qemu/qemu_capabilities.h +@@ -709,6 +709,7 @@ const char *virQEMUCapsGetBinary(virQEMUCaps *qemuCaps); + virArch virQEMUCapsGetArch(virQEMUCaps *qemuCaps); + unsigned int virQEMUCapsGetVersion(virQEMUCaps *qemuCaps); + const char *virQEMUCapsGetPackage(virQEMUCaps *qemuCaps); ++bool virQEMUCapsHasStratovirt(virQEMUCaps *qemuCaps); + + virDomainCapsCPUModels *virQEMUCapsGetCPUModels(virQEMUCaps *qemuCaps, + virDomainVirtType type, +-- +2.45.2.windows.1 + diff --git a/chardev-use-path-instead-of-fd-for-stratovirt.patch b/chardev-use-path-instead-of-fd-for-stratovirt.patch new file mode 100644 index 0000000..6f9a5ac --- /dev/null +++ b/chardev-use-path-instead-of-fd-for-stratovirt.patch @@ -0,0 +1,45 @@ +From 4d186c6a0a88c9664ffd5710a111819410d03337 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Sat, 24 May 2025 18:50:52 +0800 +Subject: [PATCH 6/9] chardev:use path instead of fd for stratovirt + +Signed-off-by: fangyi +--- + src/qemu/qemu_command.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 20d04e858b..a6a174228f 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -1286,7 +1286,8 @@ qemuBuildChrChardevReconnectStr(virBuffer *buf, + + static char * + qemuBuildChardevStr(const virDomainChrSourceDef *dev, +- const char *charAlias) ++ const char *charAlias, ++ bool hasStratovirt) + { + + qemuDomainChrSourcePrivate *chrSourcePriv = QEMU_DOMAIN_CHR_SOURCE_PRIVATE(dev); +@@ -1391,7 +1392,7 @@ qemuBuildChardevStr(const virDomainChrSourceDef *dev, + + case VIR_DOMAIN_CHR_TYPE_UNIX: + virBufferAsprintf(&buf, "socket,id=%s", charAlias); +- if (chrSourcePriv->directfd) { ++ if (chrSourcePriv->directfd && !hasStratovirt) { + virBufferAsprintf(&buf, ",fd=%s", qemuFDPassDirectGetPath(chrSourcePriv->directfd)); + } else { + virBufferAddLit(&buf, ",path="); +@@ -1544,7 +1545,7 @@ qemuBuildChardevCommand(virCommand *cmd, + + qemuFDPassTransferCommand(chrSourcePriv->logfd, cmd); + +- if (!(charstr = qemuBuildChardevStr(dev, charAlias))) ++ if (!(charstr = qemuBuildChardevStr(dev, charAlias, virQEMUCapsHasStratovirt(qemuCaps)))) + return -1; + + virCommandAddArgList(cmd, "-chardev", charstr, NULL); +-- +2.45.2.windows.1 + diff --git a/cpu-Add-new-Dharma-CPU-model.patch b/cpu-Add-new-Dharma-CPU-model.patch new file mode 100644 index 0000000..ff166df --- /dev/null +++ b/cpu-Add-new-Dharma-CPU-model.patch @@ -0,0 +1,131 @@ +From 17ef48f1ce6047d2c886ff4c5d6ee934a3ae5926 Mon Sep 17 00:00:00 2001 +From: Yanjing Zhou +Date: Wed, 29 May 2024 04:53:33 -0400 +Subject: [PATCH 1/9] cpu: Add new Dharma CPU model + +Add Hygon Dharma CPU model to the processor model. + +Signed-off-by: Yanjing Zhou +--- + src/cpu_map/index.xml | 1 + + src/cpu_map/meson.build | 1 + + src/cpu_map/x86_Dharma.xml | 83 ++++++++++++++++++++++++++++++++++++++ + 3 files changed, 85 insertions(+) + create mode 100644 src/cpu_map/x86_Dharma.xml + +diff --git a/src/cpu_map/index.xml b/src/cpu_map/index.xml +index d2c5af5797..5d18a4aed6 100644 +--- a/src/cpu_map/index.xml ++++ b/src/cpu_map/index.xml +@@ -74,6 +74,7 @@ + + + ++ + + + +diff --git a/src/cpu_map/meson.build b/src/cpu_map/meson.build +index ae5293e85f..ca4934d363 100644 +--- a/src/cpu_map/meson.build ++++ b/src/cpu_map/meson.build +@@ -36,6 +36,7 @@ cpumap_data = [ + 'x86_coreduo.xml', + 'x86_cpu64-rhel5.xml', + 'x86_cpu64-rhel6.xml', ++ 'x86_Dharma.xml', + 'x86_Dhyana.xml', + 'x86_EPYC-IBPB.xml', + 'x86_EPYC.xml', +diff --git a/src/cpu_map/x86_Dharma.xml b/src/cpu_map/x86_Dharma.xml +new file mode 100644 +index 0000000000..bf20116087 +--- /dev/null ++++ b/src/cpu_map/x86_Dharma.xml +@@ -0,0 +1,83 @@ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +-- +2.45.2.windows.1 + diff --git a/iommufd-Support-configuring-iommufd-backends-for-qem.patch b/iommufd-Support-configuring-iommufd-backends-for-qem.patch new file mode 100644 index 0000000..d1ec96f --- /dev/null +++ b/iommufd-Support-configuring-iommufd-backends-for-qem.patch @@ -0,0 +1,151 @@ +From 3fbe8ffb68e5ad727d0f7099a1038f722e60fe33 Mon Sep 17 00:00:00 2001 +From: libai +Date: Sat, 29 Mar 2025 10:33:45 +0800 +Subject: [PATCH 2/9] iommufd:Support configuring iommufd backends for qemu in + XML + +IOMMUFD is the interface exposed by the Linux kernel to +user state virtualization programs for operating iommu. +Qemu has implemented iommufd backend. +This patch supports configuring a specified number of iommufds +for qemu cmd in XML. + +XML format reference: + +2 + +This XML will be parsed into 2 iommufd objects and +two iommufd objects will be constructed in the qemu command line +-object {"qom-type":"iommufd", "id":"iommufd1"} +-object {"qom-type":"iommufd", "id":"iommufd2"} + +Signed-off-by: libai +--- + src/conf/domain_conf.c | 31 +++++++++++++++++++++++++++++++ + src/conf/domain_conf.h | 2 ++ + src/qemu/qemu_command.c | 26 ++++++++++++++++++++++++++ + 3 files changed, 59 insertions(+) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index b3475757c3..81ad207173 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -16003,6 +16003,24 @@ virDomainDefParseIOThreads(virDomainDef *def, + return virDomainIOThreadIDDefArrayInit(def, iothreads); + } + ++static int ++virDomainDefParseIOMMUFDs(virDomainDef *def, ++ xmlXPathContextPtr ctxt) ++{ ++ unsigned int iommufds = 0; ++ g_autofree char *tmp = NULL; ++ ++ tmp = virXPathString("string(./iommufds[1])", ctxt); ++ if (tmp && virStrToLong_uip(tmp, NULL, 10, &iommufds) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, ++ _("invalid iommufds count '%s'"), tmp); ++ return -1; ++ } ++ ++ def->iommufds = iommufds; ++ ++ return 0; ++} + + /* Parse the XML definition for a vcpupin + * +@@ -18360,6 +18378,9 @@ virDomainDefTunablesParse(virDomainDef *def, + if (virDomainDefParseIOThreads(def, ctxt) < 0) + return -1; + ++ if (virDomainDefParseIOMMUFDs(def, ctxt) < 0) ++ return -1; ++ + /* Extract cpu tunables. */ + if ((n = virXPathULongLong("string(./cputune/shares[1])", ctxt, + &def->cputune.shares)) < -1) { +@@ -27114,6 +27135,14 @@ virDomainDefIOThreadsFormat(virBuffer *buf, + virDomainDefaultIOThreadDefFormat(buf, def); + } + ++static void ++virDomainDefIOMMUFDsFormat(virBuffer *buf, ++ const virDomainDef *def) ++{ ++ if (def->iommufds > 0) { ++ virBufferAsprintf(buf, "%zu\n", def->iommufds); ++ } ++} + + static void + virDomainIOMMUDefFormat(virBuffer *buf, +@@ -27777,6 +27806,8 @@ virDomainDefFormatInternalSetRootName(virDomainDef *def, + + virDomainDefIOThreadsFormat(buf, def); + ++ virDomainDefIOMMUFDsFormat(buf, def); ++ + if (virDomainCputuneDefFormat(buf, def, flags) < 0) + return -1; + +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index f0e5535013..a4088c97a2 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -3001,6 +3001,8 @@ struct _virDomainDef { + + virDomainDefaultIOThreadDef *defaultIOThread; + ++ size_t iommufds; ++ + virDomainCputune cputune; + + virDomainResctrlDef **resctrls; +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 7ca4397dfe..7b2c66279f 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -7447,6 +7447,29 @@ qemuBuildIOThreadCommandLine(virCommand *cmd, + return 0; + } + ++static int ++qemuBuildIOMMUFDCommandLine(virCommand *cmd, ++ const virDomainDef *def, ++ virQEMUCaps *qemuCaps) ++{ ++ size_t i; ++ ++ /* The iommufd alias id starts at 1 */ ++ for (i = 1; i <= def->iommufds; i++) { ++ g_autoptr(virJSONValue) props = NULL; ++ g_autofree char *alias = NULL; ++ ++ alias = g_strdup_printf("iommufd%lu", i); ++ ++ if (qemuMonitorCreateObjectProps(&props, "iommufd", alias, NULL) < 0) ++ return -1; ++ ++ if (qemuBuildObjectCommandlineFromJSON(cmd, props, qemuCaps) < 0) ++ return -1; ++ } ++ ++ return 0; ++} + + static int + qemuBuildNumaCellCache(virCommand *cmd, +@@ -10513,6 +10536,9 @@ qemuBuildCommandLine(virDomainObj *vm, + if (qemuBuildIOThreadCommandLine(cmd, def, qemuCaps) < 0) + return NULL; + ++ if (qemuBuildIOMMUFDCommandLine(cmd, def, qemuCaps) < 0) ++ return NULL; ++ + if (virDomainNumaGetNodeCount(def->numa) && + qemuBuildNumaCommandLine(cfg, def, cmd, priv) < 0) + return NULL; +-- +2.45.2.windows.1 + diff --git a/libvirt.spec b/libvirt.spec index 3bc1dc1..1937d5b 100644 --- a/libvirt.spec +++ b/libvirt.spec @@ -262,7 +262,7 @@ Summary: Library providing a simple virtualization API Name: libvirt Version: 9.10.0 -Release: 14 +Release: 15 License: LGPLv2+ URL: https://libvirt.org/ @@ -329,6 +329,16 @@ Patch0055: Automatically-unbind-all-devices-driver-under-same-r.patch Patch0056: conf-qemu-add-libvirt-support-reuse-id-for-hygon-CSV.patch Patch0057: conf-qemu-support-provide-inject-secret-for-Hygon-CS.patch Patch0058: Bugfix-Enhance-the-capability-to-trace-the-shutdown-.patch +Patch0059: cpu-Add-new-Dharma-CPU-model.patch +Patch0060: qemu-cvm-support-uefi-boot-by-rom.patch +Patch0061: iommufd-Support-configuring-iommufd-backends-for-qem.patch +Patch0062: vdpa-iommufd-Support-associating-iommufd-with-vDPA-h.patch +Patch0063: capabilities-add-fun-to-determine-if-binary-is-strat.patch +Patch0064: qemu_command-unsupport-command-line-will-not-built-f.patch +Patch0065: chardev-use-path-instead-of-fd-for-stratovirt.patch +Patch0066: Revert-qemu-command-Delegate-qemuBuildDriveStr-to-SD.patch +Patch0067: Revert-qemu-Remove-pre-blockdev-PFLASH-setup.patch +Patch0068: qemu_command-get-disk-alias-from-disk-instead-of-nod.patch Requires: libvirt-daemon = %{version}-%{release} Requires: libvirt-daemon-config-network = %{version}-%{release} @@ -2620,6 +2630,18 @@ exit 0 %endif %changelog +* Mon May 26 2025 fangyi - 9.10.0-15 +- cpu-Add-new-Dharma-CPU-model.patch +- qemu-cvm-support-uefi-boot-by-rom.patch +- iommufd-Support-configuring-iommufd-backends-for-qem.patch +- vdpa-iommufd-Support-associating-iommufd-with-vDPA-h.patch +- capabilities-add-fun-to-determine-if-binary-is-strat.patch +- qemu_command-unsupport-command-line-will-not-built-f.patch +- chardev-use-path-instead-of-fd-for-stratovirt.patch +- Revert-qemu-command-Delegate-qemuBuildDriveStr-to-SD.patch +- Revert-qemu-Remove-pre-blockdev-PFLASH-setup.patch +- qemu_command-get-disk-alias-from-disk-instead-of-nod.patch + * Thu Dec 12 2024 JiaboFeng - 9.10.0-14 - Bugfix: Enhance the capability to trace the shutdown status of large VMS - conf: qemu: support provide inject secret for Hygon CSV diff --git a/qemu-cvm-support-uefi-boot-by-rom.patch b/qemu-cvm-support-uefi-boot-by-rom.patch new file mode 100644 index 0000000..6323f04 --- /dev/null +++ b/qemu-cvm-support-uefi-boot-by-rom.patch @@ -0,0 +1,45 @@ +From a65376692c1c68fc06b057a411af3807c956712a Mon Sep 17 00:00:00 2001 +From: gongchangsui +Date: Wed, 19 Mar 2025 15:36:54 +0800 +Subject: [PATCH 02/10] qemu: cvm support uefi boot by rom + +Adapted the confidential computing to support UEFI boot functionality. +For confidential virtual machines (VMs), the loader type is configured to +use ROM instead of pflash. Additionally, code-level isolation has been +implemented to separate non-confidential VM scenarios. + +Signed-off-by: gongchangsui +--- + src/qemu/qemu_validate.c | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c +index 449fb2f2d1..5894e2bd26 100644 +--- a/src/qemu/qemu_validate.c ++++ b/src/qemu/qemu_validate.c +@@ -1134,6 +1134,7 @@ qemuValidateDomainDef(const virDomainDef *def, + g_autoptr(virQEMUCaps) qemuCapsLocal = NULL; + virQEMUCaps *qemuCaps = parseOpaque; + size_t i; ++ bool isCvm = def->sec && def->sec->sectype == VIR_DOMAIN_LAUNCH_SECURITY_CVM; + + if (!qemuCaps) { + if (!(qemuCapsLocal = virQEMUCapsCacheLookup(driver->qemuCapsCache, +@@ -1200,9 +1201,11 @@ qemuValidateDomainDef(const virDomainDef *def, + def->os.arch == VIR_ARCH_AARCH64 && + (def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_EFI && + !virDomainDefHasOldStyleUEFI(def))) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +- _("ACPI requires UEFI on this architecture")); +- return -1; ++ if (!isCvm || def->os.firmware != VIR_DOMAIN_OS_DEF_FIRMWARE_NONE) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", ++ _("ACPI requires UEFI on this architecture")); ++ return -1; ++ } + } + + if (def->genidRequested && +-- +2.45.2.windows.1 + diff --git a/qemu_command-get-disk-alias-from-disk-instead-of-nod.patch b/qemu_command-get-disk-alias-from-disk-instead-of-nod.patch new file mode 100644 index 0000000..fc635dd --- /dev/null +++ b/qemu_command-get-disk-alias-from-disk-instead-of-nod.patch @@ -0,0 +1,84 @@ +From 3f7510e5c8d28706f230f89501dec986032f2455 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Mon, 26 May 2025 17:04:45 +0800 +Subject: [PATCH 9/9] qemu_command: get disk alias from disk instead of node + name for startovirt + +Signed-off-by: fangyi +--- + src/qemu/qemu_command.c | 2 +- + src/qemu/qemu_domain.c | 6 ++++-- + src/qemu/qemu_domain.h | 3 ++- + src/qemu/qemu_hotplug.c | 2 +- + 4 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 9d701ed603..c6ce598e4a 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -1888,7 +1888,7 @@ qemuBuildDiskDeviceProps(const virDomainDef *def, + if (virStorageSourceGetActualType(disk->src) == VIR_STORAGE_TYPE_VHOST_USER) { + chardev = qemuDomainGetVhostUserChrAlias(disk->info.alias); + } else { +- if (qemuDomainDiskGetBackendAlias(disk, &drive) < 0) ++ if (qemuDomainDiskGetBackendAlias(disk, &drive, virQEMUCapsHasStratovirt(qemuCaps)) < 0) + return NULL; + } + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 715b0b91ca..d2f0eea1cc 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -7918,6 +7918,7 @@ qemuDomainDiskGetTopNodename(virDomainDiskDef *disk) + * qemuDomainDiskGetBackendAlias: + * @disk: disk definition + * @backendAlias: filled with the alias of the disk storage backend ++ * @hasStratovirt: binary has "StratoVirt" or not + * + * Returns the correct alias for the disk backend. This may be the alias of + * -drive for legacy setup or the correct node name for -blockdev setups. +@@ -7929,11 +7930,12 @@ qemuDomainDiskGetTopNodename(virDomainDiskDef *disk) + */ + int + qemuDomainDiskGetBackendAlias(virDomainDiskDef *disk, +- char **backendAlias) ++ char **backendAlias, ++ bool hasStratovirt) + { + *backendAlias = NULL; + +- if (qemuDiskBusIsSD(disk->bus)) { ++ if (hasStratovirt || qemuDiskBusIsSD(disk->bus)) { + if (!(*backendAlias = qemuAliasDiskDriveFromDisk(disk))) + return -1; + +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index c90a361e8a..ff6da19cba 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -743,7 +743,8 @@ qemuDomainDiskGetTopNodename(virDomainDiskDef *disk) + ATTRIBUTE_NONNULL(1); + + int qemuDomainDiskGetBackendAlias(virDomainDiskDef *disk, +- char **backendAlias) ++ char **backendAlias, ++ bool hasStratovirt) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) G_GNUC_WARN_UNUSED_RESULT; + + int qemuDomainStorageSourceChainAccessAllow(virQEMUDriver *driver, +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 907971b41f..5342f8e31e 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -482,7 +482,7 @@ qemuDomainChangeMediaBlockdev(virDomainObj *vm, + if (!(newbackend = qemuBuildStorageSourceChainAttachPrepareBlockdev(newsrc))) + return -1; + +- if (qemuDomainDiskGetBackendAlias(disk, &nodename) < 0) ++ if (qemuDomainDiskGetBackendAlias(disk, &nodename, false) < 0) + return -1; + } + +-- +2.45.2.windows.1 + diff --git a/qemu_command-unsupport-command-line-will-not-built-f.patch b/qemu_command-unsupport-command-line-will-not-built-f.patch new file mode 100644 index 0000000..41c6c73 --- /dev/null +++ b/qemu_command-unsupport-command-line-will-not-built-f.patch @@ -0,0 +1,72 @@ +From b0127bb9b29922e58536a6cd6c4ae69523a257b4 Mon Sep 17 00:00:00 2001 +From: fangyi +Date: Sat, 24 May 2025 18:17:26 +0800 +Subject: [PATCH 5/9] qemu_command:unsupport command line will not built for + stratovirt + +Signed-off-by: fangyi +--- + src/qemu/qemu_command.c | 9 ++++++++- + src/qemu/qemu_migration_params.c | 3 ++- + src/qemu/qemu_process.c | 4 +++- + 3 files changed, 13 insertions(+), 3 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 40bab084fa..20d04e858b 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -310,6 +310,11 @@ qemuBuildMasterKeyCommandLine(virCommand *cmd, + g_autofree char *path = NULL; + g_autoptr(virJSONValue) props = NULL; + ++ if (virQEMUCapsHasStratovirt(priv->qemuCaps)) { ++ VIR_INFO("secret object is not supported by Stratovirt"); ++ return 0; ++ } ++ + if (!(alias = qemuDomainGetMasterKeyAlias())) + return -1; + +@@ -10639,7 +10644,9 @@ qemuBuildCommandLine(virDomainObj *vm, + if (qemuBuildInputCommandLine(cmd, def, qemuCaps) < 0) + return NULL; + +- if (qemuBuildAudioCommandLine(cmd, def) < 0) ++ /* audio device is not supported by stratovirt. */ ++ if (!virQEMUCapsHasStratovirt(qemuCaps) && ++ qemuBuildAudioCommandLine(cmd, def) < 0) + return NULL; + + if (qemuBuildGraphicsCommandLine(cfg, cmd, def, qemuCaps) < 0) +diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_params.c +index 5c75fa4d8e..69cc049d66 100644 +--- a/src/qemu/qemu_migration_params.c ++++ b/src/qemu/qemu_migration_params.c +@@ -1573,7 +1573,8 @@ qemuMigrationCapsCheck(virDomainObj *vm, + } + } + +- if (!reconnect) { ++ /* the qmp "migrate-set-capabilities" is not supported by stratovirt */ ++ if (!reconnect && !virQEMUCapsHasStratovirt(priv->qemuCaps)) { + g_autoptr(virBitmap) migEvent = virBitmapNew(QEMU_MIGRATION_CAP_LAST); + + ignore_value(virBitmapSetBit(migEvent, QEMU_MIGRATION_CAP_EVENTS)); +diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c +index 89dfd23c84..9c8d787df7 100644 +--- a/src/qemu/qemu_process.c ++++ b/src/qemu/qemu_process.c +@@ -8215,7 +8215,9 @@ qemuProcessLaunch(virConnectPtr conn, + if (qemuProcessSetupBalloon(vm, asyncJob) < 0) + goto cleanup; + +- if (qemuProcessSetupDiskThrottling(vm, asyncJob) < 0) ++ /* disk throttling is not supported by stratovirt */ ++ if (!virQEMUCapsHasStratovirt(priv->qemuCaps) && ++ qemuProcessSetupDiskThrottling(vm, asyncJob) < 0) + goto cleanup; + + /* Since CPUs were not started yet, the balloon could not return the memory +-- +2.45.2.windows.1 + diff --git a/vdpa-iommufd-Support-associating-iommufd-with-vDPA-h.patch b/vdpa-iommufd-Support-associating-iommufd-with-vDPA-h.patch new file mode 100644 index 0000000..fc7eee0 --- /dev/null +++ b/vdpa-iommufd-Support-associating-iommufd-with-vDPA-h.patch @@ -0,0 +1,96 @@ +From 895a24f02e29ce32954b5153b537a1cfe713dd26 Mon Sep 17 00:00:00 2001 +From: libai +Date: Sat, 29 Mar 2025 10:45:45 +0800 +Subject: [PATCH 3/9] vdpa/iommufd:Support associating iommufd with vDPA + hostdev in XML + +Multiple vDPA devices can share iommu resources by associating the same iommufd backend +VDPA device XML reference: + + + +This XML will be parsed as: +-device { + "driver":"vhost-vdpa-device-pci", + "id":"hostdev0", + "iommufd","iommufd1" +} + +The iommufd is a property that many types of hostdev devices may use, +so it is considered a member of hostdev. + +Signed-off-by: libai +--- + src/conf/domain_conf.c | 12 ++++++++++++ + src/conf/domain_conf.h | 1 + + src/qemu/qemu_command.c | 7 +++++++ + 3 files changed, 20 insertions(+) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 81ad207173..9643b9ce01 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -6226,6 +6226,13 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, + + model = virXMLPropString(node, "model"); + ++ if (virXMLPropUInt(node, "iommufd", 10, VIR_XML_PROP_NONZERO, ++ &def->iommufd) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, "%s", ++ _("The 'iommufd' attribute in element cannot be resolved.")); ++ return -1; ++ } ++ + /* @type is passed in from the caller rather than read from the + * xml document, because it is specified in different places for + * different kinds of defs - it is an attribute of +@@ -26329,6 +26336,11 @@ virDomainHostdevDefFormat(virBuffer *buf, + virTristateSwitchTypeToString(mdevsrc->ramfb)); + } + ++ if (def->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_VDPA && ++ def->iommufd) { ++ virBufferAsprintf(buf, " iommufd='%u'", def->iommufd); ++ } ++ + } + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index a4088c97a2..180f092c06 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -384,6 +384,7 @@ struct _virDomainHostdevDef { + bool missing; + bool readonly; + bool shareable; ++ unsigned int iommufd; + virTristateBool writeFiltering; + union { + virDomainHostdevSubsys subsys; +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 7b2c66279f..40bab084fa 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -5023,11 +5023,18 @@ qemuBuildHostdevVDPADevProps(const virDomainDef *def, + { + g_autoptr(virJSONValue) props = NULL; + virDomainHostdevSubsysVDPA *vdpasrc = &dev->source.subsys.u.vdpa; ++ g_autofree char *iommufd = NULL; ++ ++ if (dev->iommufd) { ++ iommufd = g_strdup_printf("iommufd%u", dev->iommufd); ++ } ++ + if (virJSONValueObjectAdd(&props, + "s:driver", "vhost-vdpa-device-pci", + "s:id", dev->info->alias, + "s:vhostdev", vdpasrc->devpath, + "p:bootindex", dev->info->bootIndex, ++ "S:iommufd", iommufd, + NULL) < 0) + return NULL; + +-- +2.45.2.windows.1 + -- Gitee