From 3e5111bb717a4e00546413767373121b9715b44d Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 01 2017 03:19:24 +0000 Subject: import libvirt-3.2.0-14.el7 --- diff --git a/.gitignore b/.gitignore index 228728d..1d9289f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/libvirt-2.0.0.tar.xz +SOURCES/libvirt-3.2.0.tar.xz diff --git a/.libvirt.metadata b/.libvirt.metadata index 8f70851..e2e8aba 100644 --- a/.libvirt.metadata +++ b/.libvirt.metadata @@ -1 +1 @@ -9a923b06df23f7a5526e4ec679cdadf4eb35a38f SOURCES/libvirt-2.0.0.tar.xz +47d4b443fdf1e268589529018c436bbc4b413a7c SOURCES/libvirt-3.2.0.tar.xz diff --git a/SOURCES/libvirt-Add-QEMU_CAPS_DEVICE_INTEL_IOMMU.patch b/SOURCES/libvirt-Add-QEMU_CAPS_DEVICE_INTEL_IOMMU.patch deleted file mode 100644 index 51ec460..0000000 --- a/SOURCES/libvirt-Add-QEMU_CAPS_DEVICE_INTEL_IOMMU.patch +++ /dev/null @@ -1,105 +0,0 @@ -From d9e2deb0b6928f213d11f5c6e82ac17c3cad0b3b Mon Sep 17 00:00:00 2001 -Message-Id: -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Mon, 25 Jul 2016 10:24:57 +0200 -Subject: [PATCH] Add QEMU_CAPS_DEVICE_INTEL_IOMMU -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Check whether QEMU supports -device intel-iommu - -Note that the presence of this option does not mean that it's -usable because of a bug in earlier QEMU versions, but it's -better than nothing. - -https://bugzilla.redhat.com/show_bug.cgi?id=1235581 -(cherry picked from commit 8e7e79738d47d7881eb6ccc61ddcb0cfba418d94) -Signed-off-by: Ján Tomko - - Conflicts: - src/qemu/qemu_capabilities.c - src/qemu/qemu_capabilities.h - tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml - tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml - tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml - Downstream is missing QEMU_CAPS_DISPLAY ---- - src/qemu/qemu_capabilities.c | 2 ++ - src/qemu/qemu_capabilities.h | 1 + - tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + - tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + - tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + - 5 files changed, 6 insertions(+) - -diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c -index 9f1c0e1..b35948d 100644 ---- a/src/qemu/qemu_capabilities.c -+++ b/src/qemu/qemu_capabilities.c -@@ -337,6 +337,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, - "drive-detect-zeroes", - - "tls-creds-x509", /* 230 */ -+ "intel-iommu", - ); - - -@@ -1566,6 +1567,7 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { - { "pxb", QEMU_CAPS_DEVICE_PXB }, - { "pxb-pcie", QEMU_CAPS_DEVICE_PXB_PCIE }, - { "tls-creds-x509", QEMU_CAPS_OBJECT_TLS_CREDS_X509 }, -+ { "intel-iommu", QEMU_CAPS_DEVICE_INTEL_IOMMU }, - }; - - static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = { -diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h -index 9d891c8..379aff0 100644 ---- a/src/qemu/qemu_capabilities.h -+++ b/src/qemu/qemu_capabilities.h -@@ -370,6 +370,7 @@ typedef enum { - - /* 230 */ - QEMU_CAPS_OBJECT_TLS_CREDS_X509, /* -object tls-creds-x509 */ -+ QEMU_CAPS_DEVICE_INTEL_IOMMU, /* -device intel-iommu */ - - QEMU_CAPS_LAST /* this must always be the last item */ - } virQEMUCapsFlags; -diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml -index 112ac95..98c260c 100644 ---- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml -@@ -182,6 +182,7 @@ - - - -+ - 2004000 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml -index 8157985..590c8c1 100644 ---- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml -@@ -187,6 +187,7 @@ - - - -+ - 2005000 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -index 1d503dd..128ac11 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -@@ -193,6 +193,7 @@ - - - -+ - 2006000 - 0 - --- -2.9.2 - diff --git a/SOURCES/libvirt-Add-USB-addresses-to-qemuhotplug-test-cases.patch b/SOURCES/libvirt-Add-USB-addresses-to-qemuhotplug-test-cases.patch deleted file mode 100644 index aeb6ca8..0000000 --- a/SOURCES/libvirt-Add-USB-addresses-to-qemuhotplug-test-cases.patch +++ /dev/null @@ -1,64 +0,0 @@ -From 44efa3d179e355827796930f8d17862029fb9747 Mon Sep 17 00:00:00 2001 -Message-Id: <44efa3d179e355827796930f8d17862029fb9747@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:46 +0200 -Subject: [PATCH] Add USB addresses to qemuhotplug test cases -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -This test assumes the XML will be the same after formatting. -Add USB addresses to it to keep it working when we autoassign them. - -(cherry picked from commit 3681e0a9feb50b54a4097eb11b5c6cfd48522994) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - .../qemuhotplug-console-compat-2-live+console-virtio.xml | 1 + - tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml | 1 + - tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml | 4 +++- - 3 files changed, 5 insertions(+), 1 deletion(-) - -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2-live+console-virtio.xml b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2-live+console-virtio.xml -index 3495ee6..7ca36d5 100644 ---- a/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2-live+console-virtio.xml -+++ b/tests/qemuhotplugtestdata/qemuhotplug-console-compat-2-live+console-virtio.xml -@@ -100,6 +100,7 @@ - - - -+
- - - -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml -index b36af27..f300940 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml -+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2-live.xml -@@ -95,6 +95,7 @@ - - - -+
- - - -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml -index 2ae104e..7b35709 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml -+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat-2.xml -@@ -78,7 +78,9 @@ - -
- -- -+ -+
-+ - - - --- -2.9.2 - diff --git a/SOURCES/libvirt-Add-VIR_DOMAIN_JOB_OPERATION-typed-parameter.patch b/SOURCES/libvirt-Add-VIR_DOMAIN_JOB_OPERATION-typed-parameter.patch new file mode 100644 index 0000000..adafe29 --- /dev/null +++ b/SOURCES/libvirt-Add-VIR_DOMAIN_JOB_OPERATION-typed-parameter.patch @@ -0,0 +1,114 @@ +From 16dad808f19120275bc57e952968840417e0d091 Mon Sep 17 00:00:00 2001 +Message-Id: <16dad808f19120275bc57e952968840417e0d091@dist-git> +From: Jiri Denemark +Date: Wed, 26 Apr 2017 11:59:59 +0200 +Subject: [PATCH] Add VIR_DOMAIN_JOB_OPERATION typed parameter + +The parameter is reported by virDomainGetJobStats API and +VIR_DOMAIN_EVENT_ID_JOB_COMPLETED event and it can be used to identify +the operation (migration, snapshot, ...) to which the reported +statistics belong. + +https://bugzilla.redhat.com/show_bug.cgi?id=1441563 + +Signed-off-by: Jiri Denemark +(cherry picked from commit b1c79d785f9385eb4ebd5e71d1d44e67f744f4d9) +Signed-off-by: Jiri Denemark +--- + include/libvirt/libvirt-domain.h | 25 +++++++++++++++++++++++++ + tools/virsh-domain.c | 29 +++++++++++++++++++++++++++++ + 2 files changed, 54 insertions(+) + +diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h +index 501996bc8..c9e96a6c9 100644 +--- a/include/libvirt/libvirt-domain.h ++++ b/include/libvirt/libvirt-domain.h +@@ -3117,6 +3117,31 @@ int virDomainGetJobStats(virDomainPtr domain, + unsigned int flags); + int virDomainAbortJob(virDomainPtr dom); + ++typedef enum { ++ VIR_DOMAIN_JOB_OPERATION_UNKNOWN = 0, ++ VIR_DOMAIN_JOB_OPERATION_START = 1, ++ VIR_DOMAIN_JOB_OPERATION_SAVE = 2, ++ VIR_DOMAIN_JOB_OPERATION_RESTORE = 3, ++ VIR_DOMAIN_JOB_OPERATION_MIGRATION_IN = 4, ++ VIR_DOMAIN_JOB_OPERATION_MIGRATION_OUT = 5, ++ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT = 6, ++ VIR_DOMAIN_JOB_OPERATION_SNAPSHOT_REVERT = 7, ++ VIR_DOMAIN_JOB_OPERATION_DUMP = 8, ++ ++# ifdef VIR_ENUM_SENTINELS ++ VIR_DOMAIN_JOB_OPERATION_LAST ++# endif ++} virDomainJobOperation; ++ ++/** ++ * VIR_DOMAIN_JOB_OPERATION: ++ * ++ * virDomainGetJobStats field: the operation which started the job as ++ * VIR_TYPED_PARAM_INT. The values correspond to the items in ++ * virDomainJobOperation enum. ++ */ ++# define VIR_DOMAIN_JOB_OPERATION "operation" ++ + /** + * VIR_DOMAIN_JOB_TIME_ELAPSED: + * +diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c +index 4b6c13ce4..bc0ded686 100644 +--- a/tools/virsh-domain.c ++++ b/tools/virsh-domain.c +@@ -5754,6 +5754,26 @@ virshDomainJobToString(int type) + return str ? _(str) : _("unknown"); + } + ++VIR_ENUM_DECL(virshDomainJobOperation); ++VIR_ENUM_IMPL(virshDomainJobOperation, ++ VIR_DOMAIN_JOB_OPERATION_LAST, ++ N_("Unknown"), ++ N_("Start"), ++ N_("Save"), ++ N_("Restore"), ++ N_("Incoming migration"), ++ N_("Outgoing migration"), ++ N_("Snapshot"), ++ N_("Snapshot revert"), ++ N_("Dump")) ++ ++static const char * ++virshDomainJobOperationToString(int op) ++{ ++ const char *str = virshDomainJobOperationTypeToString(op); ++ return str ? _(str) : _("unknown"); ++} ++ + static bool + cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) + { +@@ -5767,6 +5787,7 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) + unsigned long long value; + unsigned int flags = 0; + int ivalue; ++ int op; + int rc; + + if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) +@@ -5836,6 +5857,14 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd) + goto cleanup; + } + ++ op = VIR_DOMAIN_JOB_OPERATION_UNKNOWN; ++ if ((rc = virTypedParamsGetInt(params, nparams, ++ VIR_DOMAIN_JOB_OPERATION, &op)) < 0) ++ goto save_error; ++ ++ vshPrint(ctl, "%-17s %-12s\n", _("Operation:"), ++ virshDomainJobOperationToString(op)); ++ + vshPrint(ctl, "%-17s %-12llu ms\n", _("Time elapsed:"), info.timeElapsed); + if ((rc = virTypedParamsGetULLong(params, nparams, + VIR_DOMAIN_JOB_TIME_ELAPSED_NET, +-- +2.12.2 + diff --git a/SOURCES/libvirt-Add-functions-for-adding-USB-controllers-to-addrs.patch b/SOURCES/libvirt-Add-functions-for-adding-USB-controllers-to-addrs.patch deleted file mode 100644 index 1197d15..0000000 --- a/SOURCES/libvirt-Add-functions-for-adding-USB-controllers-to-addrs.patch +++ /dev/null @@ -1,181 +0,0 @@ -From 10bbdca5f7957403ea9baa4e007c8d5a18f23148 Mon Sep 17 00:00:00 2001 -Message-Id: <10bbdca5f7957403ea9baa4e007c8d5a18f23148@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:51 +0200 -Subject: [PATCH] Add functions for adding USB controllers to addrs -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Walk through all the usb controllers in the domain definition -and create the corresponding structures in the virDomainUSBAddressSet. - -(cherry picked from commit 6b3e4e2bea91b1247485da0987f98ccbe30e0629) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - src/conf/domain_addr.c | 121 +++++++++++++++++++++++++++++++++++++++++++++++ - src/conf/domain_addr.h | 4 ++ - src/libvirt_private.syms | 1 + - 3 files changed, 126 insertions(+) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 658aad5..ea37a42 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1326,3 +1326,124 @@ virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs) - VIR_FREE(addrs->buses); - VIR_FREE(addrs); - } -+ -+ -+static size_t -+virDomainUSBAddressControllerModelToPorts(virDomainControllerDefPtr cont) -+{ -+ int model = cont->model; -+ -+ if (model == -1) -+ model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI; -+ -+ switch ((virDomainControllerModelUSB) model) { -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX3_UHCI: -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_PIIX4_UHCI: -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_VT82C686B_UHCI: -+ return 2; -+ -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_EHCI: -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_EHCI1: -+ return 6; -+ -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI1: -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI2: -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_ICH9_UHCI3: -+ /* These have two ports each and are used to provide USB1.1 -+ * ports while ICH9_EHCI1 provides 6 USB2.0 ports. -+ * Ignore these since we will add the EHCI1 too. */ -+ return 0; -+ -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI: -+ return 3; -+ -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI: -+ if (cont->opts.usbopts.ports != -1) -+ return cont->opts.usbopts.ports; -+ return 4; -+ -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE: -+ case VIR_DOMAIN_CONTROLLER_MODEL_USB_LAST: -+ break; -+ } -+ return 0; -+} -+ -+ -+static virDomainUSBAddressHubPtr -+virDomainUSBAddressHubNew(size_t nports) -+{ -+ virDomainUSBAddressHubPtr hub = NULL, ret = NULL; -+ -+ if (VIR_ALLOC(hub) < 0) -+ goto cleanup; -+ -+ if (!(hub->portmap = virBitmapNew(nports))) -+ goto cleanup; -+ -+ if (VIR_ALLOC_N(hub->ports, nports) < 0) -+ goto cleanup; -+ hub->nports = nports; -+ -+ ret = hub; -+ hub = NULL; -+ cleanup: -+ virDomainUSBAddressHubFree(hub); -+ return ret; -+} -+ -+ -+static int -+virDomainUSBAddressSetAddController(virDomainUSBAddressSetPtr addrs, -+ virDomainControllerDefPtr cont) -+{ -+ size_t nports = virDomainUSBAddressControllerModelToPorts(cont); -+ virDomainUSBAddressHubPtr hub = NULL; -+ int ret = -1; -+ -+ VIR_DEBUG("Adding a USB controller model=%s with %zu ports", -+ virDomainControllerModelUSBTypeToString(cont->model), -+ nports); -+ -+ /* Skip UHCI{1,2,3} companions; only add the EHCI1 */ -+ if (nports == 0) -+ return 0; -+ -+ if (addrs->nbuses <= cont->idx) { -+ if (VIR_EXPAND_N(addrs->buses, addrs->nbuses, cont->idx - addrs->nbuses + 1) < 0) -+ goto cleanup; -+ } else if (addrs->buses[cont->idx]) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("Duplicate USB controllers with index %u"), -+ cont->idx); -+ goto cleanup; -+ } -+ -+ if (!(hub = virDomainUSBAddressHubNew(nports))) -+ goto cleanup; -+ -+ addrs->buses[cont->idx] = hub; -+ hub = NULL; -+ -+ ret = 0; -+ cleanup: -+ virDomainUSBAddressHubFree(hub); -+ return ret; -+} -+ -+ -+int -+virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, -+ virDomainDefPtr def) -+{ -+ size_t i; -+ -+ for (i = 0; i < def->ncontrollers; i++) { -+ virDomainControllerDefPtr cont = def->controllers[i]; -+ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) { -+ if (virDomainUSBAddressSetAddController(addrs, cont) < 0) -+ return -1; -+ } -+ } -+ return 0; -+} -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index 168d3ed..2bd4a0d 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -269,6 +269,10 @@ typedef struct _virDomainUSBAddressSet virDomainUSBAddressSet; - typedef virDomainUSBAddressSet *virDomainUSBAddressSetPtr; - - virDomainUSBAddressSetPtr virDomainUSBAddressSetCreate(void); -+ -+int virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, -+ virDomainDefPtr def) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs); - - #endif /* __DOMAIN_ADDR_H__ */ -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 49f8d6c..f0fed8e 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -110,6 +110,7 @@ virDomainPCIControllerModelToConnectType; - virDomainUSBAddressPortFormat; - virDomainUSBAddressPortFormatBuf; - virDomainUSBAddressPortIsValid; -+virDomainUSBAddressSetAddControllers; - virDomainUSBAddressSetCreate; - virDomainUSBAddressSetFree; - virDomainVirtioSerialAddrAssign; --- -2.9.2 - diff --git a/SOURCES/libvirt-Add-functions-for-adding-USB-hubs-to-addrs.patch b/SOURCES/libvirt-Add-functions-for-adding-USB-hubs-to-addrs.patch deleted file mode 100644 index 8b163fa..0000000 --- a/SOURCES/libvirt-Add-functions-for-adding-USB-hubs-to-addrs.patch +++ /dev/null @@ -1,157 +0,0 @@ -From 9798935b4b81d153f59116707e7708e7a8988b05 Mon Sep 17 00:00:00 2001 -Message-Id: <9798935b4b81d153f59116707e7708e7a8988b05@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:52 +0200 -Subject: [PATCH] Add functions for adding USB hubs to addrs -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Walk through all the usb hubs in the domain definition -that have a USB address specified, create the -corresponding structures in the virDomainUSBAddressSet -and mark the port it occupies as used. - -(cherry picked from commit 2f0813515e8a573a74c37850c4a90924cecebb90) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - src/conf/domain_addr.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 115 insertions(+) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index ea37a42..ad20fef 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1432,6 +1432,109 @@ virDomainUSBAddressSetAddController(virDomainUSBAddressSetPtr addrs, - } - - -+static ssize_t -+virDomainUSBAddressGetLastIdx(virDomainDeviceInfoPtr info) -+{ -+ ssize_t i; -+ for (i = VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH - 1; i > 0; i--) { -+ if (info->addr.usb.port[i] != 0) -+ break; -+ } -+ return i; -+} -+ -+ -+/* Find the USBAddressHub structure representing the hub/controller -+ * that corresponds to the bus/port path specified by info. -+ * Returns the index of the requested port in targetIdx. -+ */ -+static virDomainUSBAddressHubPtr -+virDomainUSBAddressFindPort(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info, -+ int *targetIdx, -+ const char *portStr) -+{ -+ virDomainUSBAddressHubPtr hub = NULL; -+ ssize_t i, lastIdx; -+ -+ if (info->addr.usb.bus >= addrs->nbuses || -+ !addrs->buses[info->addr.usb.bus]) { -+ virReportError(VIR_ERR_XML_ERROR, _("Missing USB bus %u"), -+ info->addr.usb.bus); -+ return NULL; -+ } -+ hub = addrs->buses[info->addr.usb.bus]; -+ -+ lastIdx = virDomainUSBAddressGetLastIdx(info); -+ -+ for (i = 0; i < lastIdx; i++) { -+ /* ports are numbered from 1 */ -+ int portIdx = info->addr.usb.port[i] - 1; -+ -+ if (hub->nports <= portIdx) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("port %u out of range in USB address bus: %u port: %s"), -+ info->addr.usb.port[i], -+ info->addr.usb.bus, -+ portStr); -+ return NULL; -+ } -+ hub = hub->ports[portIdx]; -+ } -+ -+ *targetIdx = info->addr.usb.port[lastIdx] - 1; -+ return hub; -+} -+ -+ -+#define VIR_DOMAIN_USB_HUB_PORTS 8 -+ -+static int -+virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs, -+ virDomainHubDefPtr hub) -+{ -+ virDomainUSBAddressHubPtr targetHub = NULL, newHub = NULL; -+ int ret = -1; -+ int targetPort; -+ char *portStr = NULL; -+ -+ if (hub->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("Wrong address type for USB hub")); -+ goto cleanup; -+ } -+ -+ if (!(portStr = virDomainUSBAddressPortFormat(hub->info.addr.usb.port))) -+ goto cleanup; -+ -+ VIR_DEBUG("Adding a USB hub with 8 ports on bus=%u port=%s", -+ hub->info.addr.usb.bus, portStr); -+ -+ if (!(newHub = virDomainUSBAddressHubNew(VIR_DOMAIN_USB_HUB_PORTS))) -+ goto cleanup; -+ -+ if (!(targetHub = virDomainUSBAddressFindPort(addrs, &(hub->info), &targetPort, -+ portStr))) -+ goto cleanup; -+ -+ if (targetHub->ports[targetPort]) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("Duplicate USB hub on bus %u port %s"), -+ hub->info.addr.usb.bus, portStr); -+ goto cleanup; -+ } -+ ignore_value(virBitmapSetBit(targetHub->portmap, targetPort)); -+ targetHub->ports[targetPort] = newHub; -+ newHub = NULL; -+ -+ ret = 0; -+ cleanup: -+ virDomainUSBAddressHubFree(newHub); -+ VIR_FREE(portStr); -+ return ret; -+} -+ -+ - int - virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, - virDomainDefPtr def) -@@ -1445,5 +1548,17 @@ virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, - return -1; - } - } -+ -+ for (i = 0; i < def->nhubs; i++) { -+ virDomainHubDefPtr hub = def->hubs[i]; -+ if (hub->type == VIR_DOMAIN_HUB_TYPE_USB && -+ hub->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB && -+ virDomainUSBAddressPortIsValid(hub->info.addr.usb.port)) { -+ /* USB hubs that do not yet have an USB address have to be -+ * dealt with later */ -+ if (virDomainUSBAddressSetAddHub(addrs, hub) < 0) -+ return -1; -+ } -+ } - return 0; - } --- -2.9.2 - diff --git a/SOURCES/libvirt-Add-helper-for-removing-transient-definition.patch b/SOURCES/libvirt-Add-helper-for-removing-transient-definition.patch deleted file mode 100644 index 4a24b0b..0000000 --- a/SOURCES/libvirt-Add-helper-for-removing-transient-definition.patch +++ /dev/null @@ -1,195 +0,0 @@ -From 3cd00003acb680159d7825c6ff1745319a6f5f1a Mon Sep 17 00:00:00 2001 -Message-Id: <3cd00003acb680159d7825c6ff1745319a6f5f1a@dist-git> -From: Jiri Denemark -Date: Thu, 8 Sep 2016 15:16:58 +0200 -Subject: [PATCH] Add helper for removing transient definition - -The code for replacing domain's transient definition with the persistent -one is repeated in several places and we'll need to add one more. Let's -make a nice helper for it. - -Signed-off-by: Jiri Denemark -(cherry picked from commit 97a87333a0ac8b6b33bf4c45a7b1a526caa554cb) - -https://bugzilla.redhat.com/show_bug.cgi?id=1368774 - -Conflicts: - src/libxl/libxl_domain.c -- context - -Signed-off-by: Jiri Denemark ---- - src/conf/domain_conf.c | 19 +++++++++++++++++++ - src/conf/domain_conf.h | 1 + - src/libvirt_private.syms | 1 + - src/libxl/libxl_domain.c | 8 +------- - src/lxc/lxc_process.c | 7 +------ - src/qemu/qemu_process.c | 7 +------ - src/test/test_driver.c | 9 ++------- - src/uml/uml_driver.c | 14 ++------------ - 8 files changed, 28 insertions(+), 38 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 67c7971..edf5de2 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -2958,6 +2958,25 @@ virDomainObjSetDefTransient(virCapsPtr caps, - return ret; - } - -+ -+/* -+ * Remove the running configuration and replace it with the persistent one. -+ * -+ * @param domain domain object pointer -+ */ -+void -+virDomainObjRemoveTransientDef(virDomainObjPtr domain) -+{ -+ if (!domain->newDef) -+ return; -+ -+ virDomainDefFree(domain->def); -+ domain->def = domain->newDef; -+ domain->def->id = -1; -+ domain->newDef = NULL; -+} -+ -+ - /* - * Return the persistent domain configuration. If domain is transient, - * return the running config. -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 61ca8bd..305ae96 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2573,6 +2573,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain, - int virDomainObjSetDefTransient(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, - virDomainObjPtr domain); -+void virDomainObjRemoveTransientDef(virDomainObjPtr domain); - virDomainDefPtr - virDomainObjGetPersistentDef(virCapsPtr caps, - virDomainXMLOptionPtr xmlopt, -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 7535064..92475a2 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -422,6 +422,7 @@ virDomainObjGetShortName; - virDomainObjGetState; - virDomainObjNew; - virDomainObjParseNode; -+virDomainObjRemoveTransientDef; - virDomainObjSetDefTransient; - virDomainObjSetMetadata; - virDomainObjSetState; -diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c -index 0e26b91..ca37a33 100644 ---- a/src/libxl/libxl_domain.c -+++ b/src/libxl/libxl_domain.c -@@ -788,13 +788,7 @@ libxlDomainCleanup(libxlDriverPrivatePtr driver, - VIR_FREE(file); - } - -- if (vm->newDef) { -- virDomainDefFree(vm->def); -- vm->def = vm->newDef; -- vm->def->id = -1; -- vm->newDef = NULL; -- } -- -+ virDomainObjRemoveTransientDef(vm); - virObjectUnref(cfg); - } - -diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c -index 07eb22a..5d124ff 100644 ---- a/src/lxc/lxc_process.c -+++ b/src/lxc/lxc_process.c -@@ -246,12 +246,7 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver, - VIR_FREE(xml); - } - -- if (vm->newDef) { -- virDomainDefFree(vm->def); -- vm->def = vm->newDef; -- vm->def->id = -1; -- vm->newDef = NULL; -- } -+ virDomainObjRemoveTransientDef(vm); - virObjectUnref(cfg); - } - -diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c -index 0777c0c..e13db38 100644 ---- a/src/qemu/qemu_process.c -+++ b/src/qemu/qemu_process.c -@@ -5999,12 +5999,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, - VIR_FREE(xml); - } - -- if (vm->newDef) { -- virDomainDefFree(vm->def); -- vm->def = vm->newDef; -- vm->def->id = -1; -- vm->newDef = NULL; -- } -+ virDomainObjRemoveTransientDef(vm); - - endjob: - if (asyncJob != QEMU_ASYNC_JOB_NONE) -diff --git a/src/test/test_driver.c b/src/test/test_driver.c -index 36bbd7f..5ec27c3 100644 ---- a/src/test/test_driver.c -+++ b/src/test/test_driver.c -@@ -577,14 +577,9 @@ testDomainShutdownState(virDomainPtr domain, - virDomainObjPtr privdom, - virDomainShutoffReason reason) - { -- if (privdom->newDef) { -- virDomainDefFree(privdom->def); -- privdom->def = privdom->newDef; -- privdom->newDef = NULL; -- } -- -+ virDomainObjRemoveTransientDef(privdom); - virDomainObjSetState(privdom, VIR_DOMAIN_SHUTOFF, reason); -- privdom->def->id = -1; -+ - if (domain) - domain->id = -1; - } -diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c -index b978453..4f25f76 100644 ---- a/src/uml/uml_driver.c -+++ b/src/uml/uml_driver.c -@@ -1135,12 +1135,7 @@ static int umlStartVMDaemon(virConnectPtr conn, - if (ret < 0) { - virDomainConfVMNWFilterTeardown(vm); - umlCleanupTapDevices(vm); -- if (vm->newDef) { -- virDomainDefFree(vm->def); -- vm->def = vm->newDef; -- vm->def->id = -1; -- vm->newDef = NULL; -- } -+ virDomainObjRemoveTransientDef(vm); - } - - /* NB we don't mark it running here - we do that async -@@ -1182,12 +1177,7 @@ static void umlShutdownVMDaemon(struct uml_driver *driver, - /* Stop autodestroy in case guest is restarted */ - umlProcessAutoDestroyRemove(driver, vm); - -- if (vm->newDef) { -- virDomainDefFree(vm->def); -- vm->def = vm->newDef; -- vm->def->id = -1; -- vm->newDef = NULL; -- } -+ virDomainObjRemoveTransientDef(vm); - - driver->nactive--; - if (!driver->nactive && driver->inhibitCallback) --- -2.10.0 - diff --git a/SOURCES/libvirt-Add-support-for-CPU-cache-specification.patch b/SOURCES/libvirt-Add-support-for-CPU-cache-specification.patch index 74a11e8..2906ff9 100644 --- a/SOURCES/libvirt-Add-support-for-CPU-cache-specification.patch +++ b/SOURCES/libvirt-Add-support-for-CPU-cache-specification.patch @@ -1,5 +1,5 @@ -From ea48ec29c4f2d53b7aee1db79e63e01a4272c666 Mon Sep 17 00:00:00 2001 -Message-Id: +From a5cb43154905e2708bf90988bd2aa5f2fca6b935 Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiri Denemark Date: Mon, 24 Apr 2017 15:40:07 +0200 Subject: [PATCH] Add support for CPU cache specification @@ -16,52 +16,46 @@ allowed. Signed-off-by: Jiri Denemark (cherry picked from commit a646a6016a7c62688988f7cfaa22e1340c2ce761) -https://bugzilla.redhat.com/show_bug.cgi?id=1447612 - -Conflicts: - docs/formatdomain.html.in -- indentation changes not backported - docs/schemas/cputypes.rng -- CPU types were not separated from - domaincommon.rng - src/conf/cpu_conf.c -- virCPUDefCopyWithoutModel was not - separated from virCPUDefCopy +https://bugzilla.redhat.com/show_bug.cgi?id=1428952 Signed-off-by: Jiri Denemark --- - docs/formatdomain.html.in | 35 +++++++++++++ - docs/schemas/domaincommon.rng | 24 +++++++++ - src/conf/cpu_conf.c | 58 ++++++++++++++++++++++ + docs/formatdomain.html.in | 35 ++++++++++++ + docs/schemas/cputypes.rng | 21 ++++++++ + docs/schemas/domaincommon.rng | 3 ++ + src/conf/cpu_conf.c | 62 ++++++++++++++++++++++ src/conf/cpu_conf.h | 19 +++++++ src/libvirt_private.syms | 2 + - .../generic-cpu-cache-disable.xml | 20 ++++++++ - .../generic-cpu-cache-emulate.xml | 20 ++++++++ - .../generic-cpu-cache-passthrough.xml | 20 ++++++++ + .../generic-cpu-cache-disable.xml | 20 +++++++ + .../generic-cpu-cache-emulate.xml | 20 +++++++ + .../generic-cpu-cache-passthrough.xml | 20 +++++++ tests/genericxml2xmltest.c | 4 ++ - 9 files changed, 202 insertions(+) + 10 files changed, 206 insertions(+) create mode 100644 tests/genericxml2xmlindata/generic-cpu-cache-disable.xml create mode 100644 tests/genericxml2xmlindata/generic-cpu-cache-emulate.xml create mode 100644 tests/genericxml2xmlindata/generic-cpu-cache-passthrough.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index e9b7bad9a..cbaf078ff 100644 +index aae5e9c07..aee1e1442 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in -@@ -1175,6 +1175,7 @@ - <model fallback='allow'>core2duo</model> - <vendor>Intel</vendor> - <topology sockets='1' cores='2' threads='1'/> -+ <cache level='3' mode='emulate'/> - <feature policy='disable' name='lahf_lm'/> - </cpu> - ... -@@ -1188,6 +1189,7 @@ +@@ -1198,6 +1198,7 @@ + <model fallback='allow'>core2duo</model> + <vendor>Intel</vendor> + <topology sockets='1' cores='2' threads='1'/> ++ <cache level='3' mode='emulate'/> + <feature policy='disable' name='lahf_lm'/> + </cpu> + ... +@@ -1211,6 +1212,7 @@
-   <cpu mode='host-passthrough'>
-+    <cache mode='passthrough'/>
-     <feature policy='disable' name='lahf_lm'/>
-   ...
+ <cpu mode='host-passthrough'> ++ <cache mode='passthrough'/> + <feature policy='disable' name='lahf_lm'/> + ... -@@ -1365,6 +1367,39 @@ +@@ -1431,6 +1433,39 @@ Since 0.8.5 the policy attribute can be omitted and will default to require. @@ -101,22 +95,12 @@ index e9b7bad9a..cbaf078ff 100644

-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index 6acc107c3..bd2823ff7 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -4388,6 +4388,9 @@ - - - -+ -+ -+ - - - -@@ -4511,6 +4514,27 @@ - +diff --git a/docs/schemas/cputypes.rng b/docs/schemas/cputypes.rng +index 8189114e3..3eef16abc 100644 +--- a/docs/schemas/cputypes.rng ++++ b/docs/schemas/cputypes.rng +@@ -142,4 +142,25 @@ + + @@ -140,14 +124,26 @@ index 6acc107c3..bd2823ff7 100644 + + + - + + +-- +2.13.0 + diff --git a/SOURCES/libvirt-Allow-omitting-USB-port.patch b/SOURCES/libvirt-Allow-omitting-USB-port.patch deleted file mode 100644 index 1300041..0000000 --- a/SOURCES/libvirt-Allow-omitting-USB-port.patch +++ /dev/null @@ -1,221 +0,0 @@ -From 986f039eddce59d25fb4060e3f12d2960c6ba100 Mon Sep 17 00:00:00 2001 -Message-Id: <986f039eddce59d25fb4060e3f12d2960c6ba100@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:48 +0200 -Subject: [PATCH] Allow omitting USB port -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -We were requiring a USB port path in the schema, but not enforcing it. -Omitting the USB port would lead to libvirt formatting it as (null). -Such domain cannot be started and will disappear after libvirtd restart -(since it cannot parse back the XML). - -Only format the port if it has been specified and mark it as optional -in the XML schema. - -(cherry picked from commit 4f903643186d0a59c4590fc8a6e8d9493c4d3d6b) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 - -Conflicts: - downstream does not assume QEMU_CAPS_SMP_TOPOLOGY ---- - docs/schemas/domaincommon.rng | 8 +++-- - src/conf/domain_conf.c | 5 ++- - src/qemu/qemu_command.c | 3 +- - .../qemuxml2argv-usb-port-missing.args | 26 ++++++++++++++++ - .../qemuxml2argv-usb-port-missing.xml | 25 +++++++++++++++ - tests/qemuxml2argvtest.c | 3 ++ - .../qemuxml2xmlout-usb-port-missing.xml | 36 ++++++++++++++++++++++ - tests/qemuxml2xmltest.c | 1 + - 8 files changed, 100 insertions(+), 7 deletions(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.xml - create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-port-missing.xml - -diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index 563cb3c..0876daa 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -4055,9 +4055,11 @@ - - - -- -- -- -+ -+ -+ -+ -+ - - - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index e6dc23d..0bd8a30 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -4859,9 +4859,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf, - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: -- virBufferAsprintf(buf, " bus='%d' port='%s'", -- info->addr.usb.bus, -- info->addr.usb.port); -+ virBufferAsprintf(buf, " bus='%d'", info->addr.usb.bus); -+ virBufferEscapeString(buf, " port='%s'", info->addr.usb.port); - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index 49412c0..af6146f 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -375,7 +375,8 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, - VIR_DOMAIN_CONTROLLER_TYPE_USB, - info->addr.usb.bus))) - goto cleanup; -- virBufferAsprintf(buf, ",bus=%s.0,port=%s", contAlias, info->addr.usb.port); -+ virBufferAsprintf(buf, ",bus=%s.0", contAlias); -+ virBufferEscapeString(buf, ",port=%s", info->addr.usb.port); - } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { - if (info->addr.spaprvio.has_reg) - virBufferAsprintf(buf, ",reg=0x%llx", info->addr.spaprvio.reg); -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args -new file mode 100644 -index 0000000..d43c58d ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args -@@ -0,0 +1,26 @@ -+LC_ALL=C \ -+PATH=/bin \ -+HOME=/home/test \ -+USER=test \ -+LOGNAME=test \ -+QEMU_AUDIO_DRV=none \ -+/usr/bin/qemu \ -+-name QEMUGuest1 \ -+-S \ -+-M pc \ -+-m 214 \ -+-smp 1 \ -+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -+-nographic \ -+-nodefconfig \ -+-nodefaults \ -+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ -+server,nowait \ -+-mon chardev=charmonitor,id=monitor,mode=readline \ -+-no-acpi \ -+-boot c \ -+-usb \ -+-device usb-hub,id=hub0,bus=usb.0 \ -+-device usb-hub,id=hub1,bus=usb.0 \ -+-device usb-mouse,id=input0,bus=usb.0 \ -+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.xml -new file mode 100644 -index 0000000..593fcd1 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.xml -@@ -0,0 +1,25 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 1 -+ -+ hvm -+ -+ -+ -+ /usr/bin/qemu -+ -+ -+ -+

-+ -+ -+
-+ -+ -+
-+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index a73db5e..4389e24 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1159,6 +1159,9 @@ mymain(void) - DO_TEST("usb-hub", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); -+ DO_TEST("usb-port-missing", -+ QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, -+ QEMU_CAPS_NODEFCONFIG); - DO_TEST("usb-ports", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-port-missing.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-port-missing.xml -new file mode 100644 -index 0000000..2e29cbd ---- /dev/null -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-usb-port-missing.xml -@@ -0,0 +1,36 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+
-+ -+ -+ -+
-+ -+ -+ -+ -+
-+ -+ -+
-+ -+ -+
-+ -+ -+ -diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c -index 7db9cb7..c6ef28c 100644 ---- a/tests/qemuxml2xmltest.c -+++ b/tests/qemuxml2xmltest.c -@@ -535,6 +535,7 @@ mymain(void) - DO_TEST("interface-server"); - DO_TEST("virtio-lun"); - -+ DO_TEST("usb-port-missing"); - DO_TEST("usb-redir"); - DO_TEST("usb-redir-filter"); - DO_TEST("usb-redir-filter-version"); --- -2.9.2 - diff --git a/SOURCES/libvirt-Assign-addresses-on-USB-device-hotplug.patch b/SOURCES/libvirt-Assign-addresses-on-USB-device-hotplug.patch deleted file mode 100644 index a4bcc75..0000000 --- a/SOURCES/libvirt-Assign-addresses-on-USB-device-hotplug.patch +++ /dev/null @@ -1,203 +0,0 @@ -From 758b25f47af79cd6da43a4bc13599b0bb64afef1 Mon Sep 17 00:00:00 2001 -Message-Id: <758b25f47af79cd6da43a4bc13599b0bb64afef1@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:56 +0200 -Subject: [PATCH] Assign addresses on USB device hotplug -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -USB disks, redirected devices, host devices and serial devices -are supported. - -(cherry picked from commit f2a781ceb075073a6033b96649f41501148d3c0c) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - src/conf/domain_addr.c | 30 ++++++++++++++++++++++ - src/conf/domain_addr.h | 5 ++++ - src/libvirt_private.syms | 1 + - src/qemu/qemu_domain_address.c | 5 ++++ - src/qemu/qemu_hotplug.c | 27 +++++++++++++++++++ - .../qemuhotplug-hotplug-base-live+disk-usb.xml | 1 + - 6 files changed, 69 insertions(+) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 3b0c205..365ee40 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1735,3 +1735,33 @@ virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr addrs, - - return 0; - } -+ -+ -+int -+virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info) -+{ -+ virDomainUSBAddressHubPtr targetHub = NULL; -+ char *portStr = NULL; -+ int targetPort; -+ int ret = -1; -+ -+ if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB || -+ !virDomainUSBAddressPortIsValid(info->addr.usb.port)) -+ return 0; -+ -+ portStr = virDomainUSBAddressPortFormat(info->addr.usb.port); -+ VIR_DEBUG("Releasing USB addr bus=%u port=%s", info->addr.usb.bus, portStr); -+ -+ if (!(targetHub = virDomainUSBAddressFindPort(addrs, info, &targetPort, -+ portStr))) -+ goto cleanup; -+ -+ ignore_value(virBitmapClearBit(targetHub->portmap, targetPort)); -+ -+ ret = 0; -+ -+ cleanup: -+ VIR_FREE(portStr); -+ return ret; -+} -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index 633aa16..cc36aed 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -293,4 +293,9 @@ int - virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr addrs, - virDomainDeviceInfoPtr info) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -+ -+int -+virDomainUSBAddressRelease(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - #endif /* __DOMAIN_ADDR_H__ */ -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 4727d39..e23bfe3 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -112,6 +112,7 @@ virDomainUSBAddressEnsure; - virDomainUSBAddressPortFormat; - virDomainUSBAddressPortFormatBuf; - virDomainUSBAddressPortIsValid; -+virDomainUSBAddressRelease; - virDomainUSBAddressReserve; - virDomainUSBAddressSetAddControllers; - virDomainUSBAddressSetAddHub; -diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c -index 21c2ecf..7499026 100644 ---- a/src/qemu/qemu_domain_address.c -+++ b/src/qemu/qemu_domain_address.c -@@ -1772,4 +1772,9 @@ qemuDomainReleaseDeviceAddress(virDomainObjPtr vm, - virDomainVirtioSerialAddrRelease(priv->vioserialaddrs, info) < 0) - VIR_WARN("Unable to release virtio-serial address on %s", - NULLSTR(devstr)); -+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB && -+ priv->usbaddrs && -+ virDomainUSBAddressRelease(priv->usbaddrs, info) < 0) -+ VIR_WARN("Unable to release USB address on %s", -+ NULLSTR(devstr)); - } -diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c -index cba0e8c..36885a3 100644 ---- a/src/qemu/qemu_hotplug.c -+++ b/src/qemu/qemu_hotplug.c -@@ -640,6 +640,13 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver, - char *devstr = NULL; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - const char *src = virDomainDiskGetSource(disk); -+ bool releaseaddr = false; -+ -+ if (priv->usbaddrs) { -+ if (virDomainUSBAddressEnsure(priv->usbaddrs, &disk->info) < 0) -+ goto cleanup; -+ releaseaddr = true; -+ } - - if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0) - goto cleanup; -@@ -685,6 +692,8 @@ qemuDomainAttachUSBMassStorageDevice(virQEMUDriverPtr driver, - virDomainDiskInsertPreAlloced(vm->def, disk); - - cleanup: -+ if (ret < 0 && releaseaddr) -+ virDomainUSBAddressRelease(priv->usbaddrs, &disk->info); - VIR_FREE(devstr); - VIR_FREE(drivestr); - virObjectUnref(cfg); -@@ -1486,6 +1495,12 @@ qemuDomainAttachChrDeviceAssignAddr(qemuDomainObjPrivatePtr priv, - return -1; - return 1; - -+ } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL && -+ chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) { -+ if (virDomainUSBAddressEnsure(priv->usbaddrs, &chr->info) < 0) -+ return -1; -+ return 1; -+ - } else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL && - chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) { - if (virDomainVirtioSerialAddrAutoAssign(NULL, priv->vioserialaddrs, -@@ -1804,11 +1819,18 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver, - { - qemuDomainObjPrivatePtr priv = vm->privateData; - char *devstr = NULL; -+ bool releaseaddr = false; - bool added = false; - bool teardowncgroup = false; - bool teardownlabel = false; - int ret = -1; - -+ if (priv->usbaddrs) { -+ if (virDomainUSBAddressEnsure(priv->usbaddrs, hostdev->info) < 0) -+ goto cleanup; -+ releaseaddr = true; -+ } -+ - if (qemuHostdevPrepareUSBDevices(driver, vm->def->name, &hostdev, 1, 0) < 0) - goto cleanup; - -@@ -1854,6 +1876,8 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver, - VIR_WARN("Unable to restore host device labelling on hotplug fail"); - if (added) - qemuHostdevReAttachUSBDevices(driver, vm->def->name, &hostdev, 1); -+ if (releaseaddr) -+ virDomainUSBAddressRelease(priv->usbaddrs, hostdev->info); - } - VIR_FREE(devstr); - return ret; -@@ -2851,6 +2875,8 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, - dev.type = VIR_DOMAIN_DEVICE_DISK; - dev.data.disk = disk; - ignore_value(qemuRemoveSharedDevice(driver, &dev, vm->def->name)); -+ if (priv->usbaddrs) -+ virDomainUSBAddressRelease(priv->usbaddrs, &disk->info); - - virDomainDiskDefFree(disk); - return 0; -@@ -2947,6 +2973,7 @@ qemuDomainRemoveUSBHostDevice(virQEMUDriverPtr driver, - virDomainHostdevDefPtr hostdev) - { - qemuHostdevReAttachUSBDevices(driver, vm->def->name, &hostdev, 1); -+ qemuDomainReleaseDeviceAddress(vm, hostdev->info, NULL); - } - - static void -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-usb.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-usb.xml -index 41039a4..cd686e6 100644 ---- a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-usb.xml -+++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+disk-usb.xml -@@ -27,6 +27,7 @@ - - - -+
- - - --- -2.9.2 - diff --git a/SOURCES/libvirt-Assign-addresses-to-USB-devices.patch b/SOURCES/libvirt-Assign-addresses-to-USB-devices.patch deleted file mode 100644 index 4597a79..0000000 --- a/SOURCES/libvirt-Assign-addresses-to-USB-devices.patch +++ /dev/null @@ -1,707 +0,0 @@ -From 2e6ca604192638d5182bb109fc83590c6d1028ae Mon Sep 17 00:00:00 2001 -Message-Id: <2e6ca604192638d5182bb109fc83590c6d1028ae@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:55 +0200 -Subject: [PATCH] Assign addresses to USB devices -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Automatically assign addresses to USB devices. - -Just like reserving, this is only done for newly defined domains. - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 -(cherry picked from commit bf182078d96476c8d5557737c1107241f280a947) -Signed-off-by: Ján Tomko ---- - src/conf/domain_addr.c | 133 ++++++++++++++++++++- - src/conf/domain_addr.h | 14 +++ - src/libvirt_private.syms | 3 + - src/qemu/qemu_domain_address.c | 65 ++++++++++ - .../qemuxml2argvdata/qemuxml2argv-bios-nvram.args | 2 +- - tests/qemuxml2argvdata/qemuxml2argv-bios.args | 2 +- - .../qemuxml2argv-controller-order.args | 8 +- - .../qemuxml2argv-disk-usb-device-removable.args | 3 +- - .../qemuxml2argv-disk-usb-device.args | 2 +- - .../qemuxml2argv-graphics-spice-timeout.args | 2 +- - .../qemuxml2argv-graphics-spice-usb-redir.args | 2 +- - ...muxml2argv-hostdev-usb-address-device-boot.args | 3 +- - .../qemuxml2argv-hostdev-usb-address-device.args | 2 +- - .../qemuxml2argv-hostdev-usb-address.args | 2 +- - .../qemuxml2argv-hugepages-numa.args | 6 +- - .../qemuxml2argv-input-usbmouse.args | 2 +- - .../qemuxml2argv-input-usbtablet.args | 2 +- - .../qemuxml2argv-pseries-usb-kbd.args | 2 +- - .../qemuxml2argv-serial-spiceport.args | 2 +- - .../qemuxml2argv-smartcard-controller.args | 2 +- - .../qemuxml2argv-smartcard-host-certificates.args | 2 +- - .../qemuxml2argv-smartcard-host.args | 2 +- - ...emuxml2argv-smartcard-passthrough-spicevmc.args | 2 +- - .../qemuxml2argv-smartcard-passthrough-tcp.args | 2 +- - .../qemuxml2argv-sound-device.args | 2 +- - .../qemuxml2argv-usb-ich9-autoassign.args | 10 +- - .../qemuxml2argv-usb-port-autoassign.args | 8 +- - .../qemuxml2argv-usb-port-missing.args | 4 +- - .../qemuxml2argv-usb-redir-boot.args | 2 +- - tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args | 2 +- - .../qemuxml2argv-usb-xhci-autoassign.args | 10 +- - 31 files changed, 260 insertions(+), 45 deletions(-) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index bbac399..3b0c205 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1489,7 +1489,7 @@ virDomainUSBAddressFindPort(virDomainUSBAddressSetPtr addrs, - - #define VIR_DOMAIN_USB_HUB_PORTS 8 - --static int -+int - virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs, - virDomainHubDefPtr hub) - { -@@ -1564,6 +1564,119 @@ virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, - } - - -+static int -+virDomainUSBAddressFindFreePort(virDomainUSBAddressHubPtr hub, -+ unsigned int *portpath, -+ unsigned int level) -+{ -+ unsigned int port; -+ ssize_t portIdx; -+ size_t i; -+ -+ /* Look for free ports on the current hub */ -+ if ((portIdx = virBitmapNextClearBit(hub->portmap, -1)) >= 0) { -+ port = portIdx + 1; -+ VIR_DEBUG("Found a free port %u at level %u", port, level); -+ portpath[level] = port; -+ return 0; -+ } -+ -+ VIR_DEBUG("No ports found on hub %p, trying the hubs on it", hub); -+ -+ if (level >= VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH - 1) -+ return -1; -+ -+ /* Recursively search through the ports that contain another hub */ -+ for (i = 0; i < hub->nports; i++) { -+ if (!hub->ports[i]) -+ continue; -+ -+ port = i + 1; -+ VIR_DEBUG("Looking at USB hub at level: %u port: %u", level, port); -+ if (virDomainUSBAddressFindFreePort(hub->ports[i], portpath, -+ level + 1) < 0) -+ continue; -+ -+ portpath[level] = port; -+ return 0; -+ } -+ return -1; -+} -+ -+ -+/* Try to find a free port on bus @bus. -+ * -+ * Returns 0 on success -+ * -1 on fatal error (OOM) -+ * -2 if there is no bus at @bus or no free port on this bus -+ */ -+static int -+virDomainUSBAddressAssignFromBus(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info, -+ size_t bus) -+{ -+ unsigned int portpath[VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH] = { 0 }; -+ virDomainUSBAddressHubPtr hub = addrs->buses[bus]; -+ char *portStr = NULL; -+ int ret = -1; -+ -+ if (!hub) -+ return -2; -+ -+ if (virDomainUSBAddressFindFreePort(hub, portpath, 0) < 0) -+ return -2; -+ -+ /* we found a free port */ -+ if (!(portStr = virDomainUSBAddressPortFormat(portpath))) -+ goto cleanup; -+ -+ info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB; -+ info->addr.usb.bus = bus; -+ memcpy(info->addr.usb.port, portpath, sizeof(portpath)); -+ VIR_DEBUG("Assigning USB addr bus=%u port=%s", -+ info->addr.usb.bus, portStr); -+ if (virDomainUSBAddressReserve(info, addrs) < 0) -+ goto cleanup; -+ -+ ret = 0; -+ cleanup: -+ VIR_FREE(portStr); -+ return ret; -+} -+ -+ -+int -+virDomainUSBAddressAssign(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info) -+{ -+ size_t i; -+ int rc; -+ -+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { -+ VIR_DEBUG("A USB port on bus %u was requested", info->addr.usb.bus); -+ if (!addrs->buses[info->addr.usb.bus]) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("USB bus %u requested but no controller " -+ "with that index is present"), info->addr.usb.bus); -+ return -1; -+ } -+ rc = virDomainUSBAddressAssignFromBus(addrs, info, info->addr.usb.bus); -+ if (rc >= -1) -+ return rc; -+ } else { -+ VIR_DEBUG("Looking for a free USB port on all the buses"); -+ for (i = 0; i < addrs->nbuses; i++) { -+ rc = virDomainUSBAddressAssignFromBus(addrs, info, i); -+ if (rc >= -1) -+ return rc; -+ } -+ } -+ -+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("No free USB ports")); -+ return -1; -+} -+ -+ - int - virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, - void *data) -@@ -1604,3 +1717,21 @@ virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, - VIR_FREE(portStr); - return ret; - } -+ -+ -+int -+virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info) -+{ -+ if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || -+ (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB && -+ !virDomainUSBAddressPortIsValid(info->addr.usb.port))) { -+ if (virDomainUSBAddressAssign(addrs, info) < 0) -+ return -1; -+ } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { -+ if (virDomainUSBAddressReserve(info, addrs) < 0) -+ return -1; -+ } -+ -+ return 0; -+} -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index a24d216..633aa16 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -273,10 +273,24 @@ virDomainUSBAddressSetPtr virDomainUSBAddressSetCreate(void); - int virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, - virDomainDefPtr def) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -+int -+virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs, -+ virDomainHubDefPtr hub) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs); - - int - virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, - void *data) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -+ -+int -+virDomainUSBAddressAssign(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -+ -+int -+virDomainUSBAddressEnsure(virDomainUSBAddressSetPtr addrs, -+ virDomainDeviceInfoPtr info) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - #endif /* __DOMAIN_ADDR_H__ */ -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index f66ccf5..4727d39 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -107,11 +107,14 @@ virDomainPCIAddressSetGrow; - virDomainPCIAddressSlotInUse; - virDomainPCIAddressValidate; - virDomainPCIControllerModelToConnectType; -+virDomainUSBAddressAssign; -+virDomainUSBAddressEnsure; - virDomainUSBAddressPortFormat; - virDomainUSBAddressPortFormatBuf; - virDomainUSBAddressPortIsValid; - virDomainUSBAddressReserve; - virDomainUSBAddressSetAddControllers; -+virDomainUSBAddressSetAddHub; - virDomainUSBAddressSetCreate; - virDomainUSBAddressSetFree; - virDomainVirtioSerialAddrAssign; -diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c -index f66b2f0..21c2ecf 100644 ---- a/src/qemu/qemu_domain_address.c -+++ b/src/qemu/qemu_domain_address.c -@@ -1622,6 +1622,63 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, - } - - -+struct qemuAssignUSBIteratorInfo { -+ virDomainUSBAddressSetPtr addrs; -+ size_t count; -+}; -+ -+ -+static int -+qemuDomainAssignUSBPortsIterator(virDomainDeviceInfoPtr info, -+ void *opaque) -+{ -+ struct qemuAssignUSBIteratorInfo *data = opaque; -+ -+ if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) -+ return 0; -+ -+ return virDomainUSBAddressAssign(data->addrs, info); -+} -+ -+ -+static int -+qemuDomainAssignUSBHubs(virDomainUSBAddressSetPtr addrs, -+ virDomainDefPtr def) -+{ -+ size_t i; -+ -+ for (i = 0; i < def->nhubs; i++) { -+ virDomainHubDefPtr hub = def->hubs[i]; -+ if (hub->type != VIR_DOMAIN_HUB_TYPE_USB) -+ continue; -+ -+ if (hub->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB && -+ virDomainUSBAddressPortIsValid(hub->info.addr.usb.port)) -+ continue; -+ if (virDomainUSBAddressAssign(addrs, &hub->info) < 0) -+ return -1; -+ -+ if (virDomainUSBAddressSetAddHub(addrs, hub) < 0) -+ return -1; -+ } -+ -+ return 0; -+} -+ -+ -+static int -+qemuDomainAssignUSBPorts(virDomainUSBAddressSetPtr addrs, -+ virDomainDefPtr def) -+{ -+ struct qemuAssignUSBIteratorInfo data = { .addrs = addrs }; -+ -+ return virDomainUSBDeviceDefForeach(def, -+ qemuDomainAssignUSBPortsIterator, -+ &data, -+ true); -+} -+ -+ - static int - qemuDomainAssignUSBAddresses(virDomainDefPtr def, - virDomainObjPtr obj) -@@ -1642,6 +1699,14 @@ qemuDomainAssignUSBAddresses(virDomainDefPtr def, - - VIR_DEBUG("Existing USB addresses have been reserved"); - -+ if (qemuDomainAssignUSBHubs(addrs, def) < 0) -+ goto cleanup; -+ -+ if (qemuDomainAssignUSBPorts(addrs, def) < 0) -+ goto cleanup; -+ -+ VIR_DEBUG("Finished assigning USB ports"); -+ - if (obj && obj->privateData) { - priv = obj->privateData; - priv->usbaddrs = addrs; -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args -index fe4e419..848a029 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram.args -@@ -21,5 +21,5 @@ QEMU_AUDIO_DRV=none \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ - -serial pty \ ---device usb-tablet,id=input0 \ -+-device usb-tablet,id=input0,bus=usb.0,port=1 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bios.args b/tests/qemuxml2argvdata/qemuxml2argv-bios.args -index 012af85..604b871 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-bios.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-bios.args -@@ -22,5 +22,5 @@ QEMU_AUDIO_DRV=none \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ - -serial pty \ ---device usb-tablet,id=input0 \ -+-device usb-tablet,id=input0,bus=usb.0,port=1 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args -index 70f3fdb..7b98beb 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-controller-order.args -@@ -19,8 +19,8 @@ nowait \ - -boot order=cna,menu=off \ - -device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \ - -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 \ ---device usb-ccid,id=ccid0 \ ---device usb-hub,id=hub0 \ -+-device usb-ccid,id=ccid0,bus=usb.0,port=1.1 \ -+-device usb-hub,id=hub0,bus=usb.0,port=1 \ - -drive file=/tmp/fdr.img,format=raw,if=none,id=drive-virtio-disk0,cache=none,\ - aio=native \ - -device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,\ -@@ -37,10 +37,10 @@ media=cdrom,id=drive-ide0-1-0,readonly=on \ - -chardev spicevmc,id=charchannel0,name=vdagent \ - -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,\ - id=channel0,name=com.redhat.spice.0 \ ---device usb-tablet,id=input0 \ -+-device usb-tablet,id=input0,bus=usb.0,port=1.2 \ - -spice port=5901,tls-port=5902,addr=0.0.0.0,x509-dir=/etc/pki/libvirt-spice \ - -vga cirrus \ - -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \ - -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \ ---device usb-host,hostbus=14,hostaddr=6,id=hostdev0 \ -+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=2 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args -index 63e2bb2..7cda592 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device-removable.args -@@ -21,5 +21,6 @@ QEMU_AUDIO_DRV=none \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ - -drive file=/tmp/usbdisk.img,format=raw,if=none,id=drive-usb-disk0 \ ---device usb-storage,drive=drive-usb-disk0,id=usb-disk0,removable=on \ -+-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk0,id=usb-disk0,\ -+removable=on \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args -index 5d1ea98..03ef44f 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb-device.args -@@ -21,5 +21,5 @@ QEMU_AUDIO_DRV=none \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ - -drive file=/tmp/usbdisk.img,format=raw,if=none,id=drive-usb-disk0 \ ---device usb-storage,drive=drive-usb-disk0,id=usb-disk0 \ -+-device usb-storage,bus=usb.0,port=1,drive=drive-usb-disk0,id=usb-disk0 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args -index c0be4ee..cead7d6 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-timeout.args -@@ -28,7 +28,7 @@ media=cdrom,id=drive-ide0-1-0,readonly=on \ - -device rtl8139,vlan=0,id=net0,mac=52:54:00:71:70:89,bus=pci.0,addr=0x7 \ - -net tap,fd=3,vlan=0,name=hostnet0 \ - -serial pty \ ---device usb-tablet,id=input0 \ -+-device usb-tablet,id=input0,bus=usb.0,port=1 \ - -spice port=5900,addr=127.0.0.1 \ - -vga std \ - -device AC97,id=sound0,bus=pci.0,addr=0x3 \ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args -index fa248b3..3f00da4 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-spice-usb-redir.args -@@ -30,7 +30,7 @@ zlib-glz-wan-compression=auto,playback-compression=on,streaming-video=filter,\ - disable-copy-paste \ - -vga cirrus \ - -chardev socket,id=charredir0,host=localhost,port=4000 \ ---device usb-redir,chardev=charredir0,id=redir0 \ -+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 \ - -chardev spicevmc,id=charredir1,name=usbredir \ - -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=4 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args -index 8c00055..ddf90c0 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device-boot.args -@@ -19,5 +19,6 @@ QEMU_AUDIO_DRV=none \ - -usb \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ ---device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bootindex=1 \ -+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bootindex=1,bus=usb.0,\ -+port=1 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args -index b5e6834..7883c61 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address-device.args -@@ -20,5 +20,5 @@ QEMU_AUDIO_DRV=none \ - -usb \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ ---device usb-host,hostbus=14,hostaddr=6,id=hostdev0 \ -+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=1 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args -index bb5d55a..d1c3e8f 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args -@@ -19,4 +19,4 @@ QEMU_AUDIO_DRV=none \ - -usb \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ ---device usb-host,hostbus=14,hostaddr=6,id=hostdev0 -+-device usb-host,hostbus=14,hostaddr=6,id=hostdev0,bus=usb.0,port=1 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args -index c5a9e53..5c356ef 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-hugepages-numa.args -@@ -46,7 +46,7 @@ id=channel0,name=org.qemu.guest_agent.0 \ - -chardev spicevmc,id=charchannel1,name=vdagent \ - -device virtserialport,bus=virtio-serial0.0,nr=2,chardev=charchannel1,\ - id=channel1,name=com.redhat.spice.0 \ ---device usb-tablet,id=input0 \ -+-device usb-tablet,id=input0,bus=usb.0,port=1 \ - -spice port=5901,tls-port=5902,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \ - -vga qxl \ - -global qxl-vga.ram_size=67108864 \ -@@ -54,7 +54,7 @@ id=channel1,name=com.redhat.spice.0 \ - -device intel-hda,id=sound0,bus=pci.0,addr=0x4 \ - -device hda-duplex,id=sound0-codec0,bus=sound0.0,cad=0 \ - -chardev spicevmc,id=charredir0,name=usbredir \ ---device usb-redir,chardev=charredir0,id=redir0 \ -+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=2 \ - -chardev spicevmc,id=charredir1,name=usbredir \ ---device usb-redir,chardev=charredir1,id=redir1 \ -+-device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=3 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x8 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args -index bd0e5c6..df96e6a 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args -@@ -19,4 +19,4 @@ QEMU_AUDIO_DRV=none \ - -usb \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ ---device usb-mouse,id=input0 -+-device usb-mouse,id=input0,bus=usb.0,port=1 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args -index 294515f..faf21d5 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args -@@ -19,4 +19,4 @@ QEMU_AUDIO_DRV=none \ - -usb \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ ---device usb-tablet,id=input0 -+-device usb-tablet,id=input0,bus=usb.0,port=1 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args -index 25c16cb..5887616 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args -@@ -22,4 +22,4 @@ server,nowait \ - -device pci-ohci,id=usb,bus=pci,addr=0x1 \ - -chardev pty,id=charserial0 \ - -device spapr-vty,chardev=charserial0,reg=0x30000000 \ ---device usb-kbd,id=input0 -+-device usb-kbd,id=input0,bus=usb.0,port=1 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args -index 246e854..f05c3f2 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-spiceport.args -@@ -23,7 +23,7 @@ server,nowait \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ - -chardev spiceport,id=charserial0,name=org.qemu.console.serial.0 \ - -device isa-serial,chardev=charserial0,id=serial0 \ ---device usb-tablet,id=input0 \ -+-device usb-tablet,id=input0,bus=usb.0,port=1 \ - -spice port=5903,tls-port=5904,addr=127.0.0.1,x509-dir=/etc/pki/libvirt-spice \ - -device qxl-vga,id=video0,ram_size=67108864,vram_size=67108864,bus=pci.0,\ - addr=0x2 \ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args -index d3135c2..beb2935 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-controller.args -@@ -19,7 +19,7 @@ server,nowait \ - -mon chardev=charmonitor,id=monitor,mode=readline \ - -no-acpi \ - -boot c \ ---device usb-ccid,id=ccid0 \ -+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ - -usb \ - -device ccid-card-emulated,backend=nss-emulated,id=smartcard0,bus=ccid0.0 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args -index 09ef26c..72cf24b 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host-certificates.args -@@ -19,7 +19,7 @@ server,nowait \ - -mon chardev=charmonitor,id=monitor,mode=readline \ - -no-acpi \ - -boot c \ ---device usb-ccid,id=ccid0 \ -+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ - -usb \ - -device ccid-card-emulated,backend=certificates,cert1=cert1,cert2=cert2,\ - cert3=cert3,db=/etc/pki/nssdb,id=smartcard0,bus=ccid0.0 \ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args -index d3135c2..beb2935 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-host.args -@@ -19,7 +19,7 @@ server,nowait \ - -mon chardev=charmonitor,id=monitor,mode=readline \ - -no-acpi \ - -boot c \ ---device usb-ccid,id=ccid0 \ -+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ - -usb \ - -device ccid-card-emulated,backend=nss-emulated,id=smartcard0,bus=ccid0.0 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args -index b618507..cdca4c4 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-spicevmc.args -@@ -19,7 +19,7 @@ server,nowait \ - -mon chardev=charmonitor,id=monitor,mode=readline \ - -no-acpi \ - -boot c \ ---device usb-ccid,id=ccid0 \ -+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ - -usb \ - -chardev spicevmc,id=charsmartcard0,name=smartcard \ - -device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args -index e0fcb49..0c526c8 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-smartcard-passthrough-tcp.args -@@ -19,7 +19,7 @@ server,nowait \ - -mon chardev=charmonitor,id=monitor,mode=readline \ - -no-acpi \ - -boot c \ ---device usb-ccid,id=ccid0 \ -+-device usb-ccid,id=ccid0,bus=usb.0,port=1 \ - -usb \ - -chardev socket,id=charsmartcard0,host=127.0.0.1,port=2001,server,nowait \ - -device ccid-card-passthru,chardev=charsmartcard0,id=smartcard0,bus=ccid0.0 \ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args -index 8d846a0..b084f4e 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound-device.args -@@ -34,5 +34,5 @@ QEMU_AUDIO_DRV=none \ - -device ich9-intel-hda,id=sound7,bus=pci.0,addr=0x8 \ - -device hda-micro,id=sound7-codec0,bus=sound7.0,cad=0 \ - -device hda-duplex,id=sound7-codec1,bus=sound7.0,cad=1 \ ---device usb-audio,id=sound8 \ -+-device usb-audio,id=sound8,bus=usb.0,port=1 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x9 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args -index faaff95..db95851 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-ich9-autoassign.args -@@ -24,9 +24,9 @@ server,nowait \ - addr=0x4 \ - -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \ - -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \ ---device usb-hub,id=hub0 \ ---device usb-hub,id=hub1 \ ---device usb-mouse,id=input0 \ ---device usb-mouse,id=input1 \ ---device usb-mouse,id=input2 \ -+-device usb-hub,id=hub0,bus=usb.0,port=1 \ -+-device usb-hub,id=hub1,bus=usb.0,port=2 \ -+-device usb-mouse,id=input0,bus=usb.0,port=3 \ -+-device usb-mouse,id=input1,bus=usb.0,port=4 \ -+-device usb-mouse,id=input2,bus=usb.0,port=5 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args -index aa80919..ac5cfdd 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-autoassign.args -@@ -21,8 +21,8 @@ server,nowait \ - -boot c \ - -usb \ - -device usb-hub,id=hub0,bus=usb.0,port=1 \ ---device usb-hub,id=hub1 \ ---device usb-mouse,id=input0 \ ---device usb-mouse,id=input1 \ ---device usb-mouse,id=input2 \ -+-device usb-hub,id=hub1,bus=usb.0,port=2 \ -+-device usb-mouse,id=input0,bus=usb.0,port=1.1 \ -+-device usb-mouse,id=input1,bus=usb.0,port=1.2 \ -+-device usb-mouse,id=input2,bus=usb.0,port=1.3 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args -index d43c58d..56c0750 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-port-missing.args -@@ -20,7 +20,7 @@ server,nowait \ - -no-acpi \ - -boot c \ - -usb \ ---device usb-hub,id=hub0,bus=usb.0 \ ---device usb-hub,id=hub1,bus=usb.0 \ -+-device usb-hub,id=hub0,bus=usb.0,port=1 \ -+-device usb-hub,id=hub1,bus=usb.0,port=2 \ - -device usb-mouse,id=input0,bus=usb.0 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args -index 53b9040..bc47963 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir-boot.args -@@ -24,7 +24,7 @@ addr=0x4 \ - -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \ - -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \ - -chardev socket,id=charredir0,host=localhost,port=4000 \ ---device usb-redir,chardev=charredir0,id=redir0,bootindex=1 \ -+-device usb-redir,chardev=charredir0,id=redir0,bootindex=1,bus=usb.0,port=1 \ - -chardev spicevmc,id=charredir1,name=usbredir \ - -device usb-redir,chardev=charredir1,id=redir1,bootindex=2,bus=usb.0,port=4 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args -index 08e8f3e..0999c97 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-redir.args -@@ -25,7 +25,7 @@ addr=0x4 \ - -device ich9-usb-uhci2,masterbus=usb.0,firstport=2,bus=pci.0,addr=0x4.0x1 \ - -device ich9-usb-uhci3,masterbus=usb.0,firstport=4,bus=pci.0,addr=0x4.0x2 \ - -chardev socket,id=charredir0,host=localhost,port=4000 \ ---device usb-redir,chardev=charredir0,id=redir0 \ -+-device usb-redir,chardev=charredir0,id=redir0,bus=usb.0,port=1 \ - -chardev spicevmc,id=charredir1,name=usbredir \ - -device usb-redir,chardev=charredir1,id=redir1,bus=usb.0,port=4 \ - -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args -index 7c5e6a5..15a9d29 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-xhci-autoassign.args -@@ -20,8 +20,8 @@ server,nowait \ - -no-acpi \ - -boot c \ - -device nec-usb-xhci,p2=8,p3=8,id=usb,bus=pci.0,addr=0x3 \ ---device usb-hub,id=hub0 \ ---device usb-hub,id=hub1 \ ---device usb-mouse,id=input0 \ ---device usb-mouse,id=input1 \ ---device usb-mouse,id=input2 -+-device usb-hub,id=hub0,bus=usb.0,port=1 \ -+-device usb-hub,id=hub1,bus=usb.0,port=2 \ -+-device usb-mouse,id=input0,bus=usb.0,port=3 \ -+-device usb-mouse,id=input1,bus=usb.0,port=4 \ -+-device usb-mouse,id=input2,bus=usb.0,port=5 --- -2.9.2 - diff --git a/SOURCES/libvirt-Auto-add-one-hub-if-there-are-too-many-USB-devices.patch b/SOURCES/libvirt-Auto-add-one-hub-if-there-are-too-many-USB-devices.patch deleted file mode 100644 index 18e9443..0000000 --- a/SOURCES/libvirt-Auto-add-one-hub-if-there-are-too-many-USB-devices.patch +++ /dev/null @@ -1,238 +0,0 @@ -From 6c058183513069522ab1b622f2e08eb1de440def Mon Sep 17 00:00:00 2001 -Message-Id: <6c058183513069522ab1b622f2e08eb1de440def@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:57 +0200 -Subject: [PATCH] Auto-add one hub if there are too many USB devices -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -When parsing a command line with USB devices that have -no address specified, QEMU automatically adds a USB hub -if the device would fill up all the available USB ports. - -To help most of the users, add one hub if there are more -USB devices than available ports. For wilder configurations, -expect the user to provide us with more hubs and/or controllers. - -(cherry picked from commit 815d98ac0bb8a4b48a412e026cb6465309e4043c) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 - -Conflicts: - downstream does not assume QEMU_CAPS_SMP_TOPOLOGY in tests ---- - src/conf/domain_addr.c | 20 +++++++++ - src/conf/domain_addr.h | 2 + - src/libvirt_private.syms | 1 + - src/qemu/qemu_domain_address.c | 48 ++++++++++++++++++++++ - .../qemuxml2argv-usb-hub-autoadd.args | 28 +++++++++++++ - .../qemuxml2argv-usb-hub-autoadd.xml | 23 +++++++++++ - tests/qemuxml2argvtest.c | 3 ++ - 7 files changed, 125 insertions(+) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.args - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.xml - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 365ee40..c3469ee 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1604,6 +1604,26 @@ virDomainUSBAddressFindFreePort(virDomainUSBAddressHubPtr hub, - } - - -+size_t -+virDomainUSBAddressCountAllPorts(virDomainDefPtr def) -+{ -+ size_t i, ret = 0; -+ -+ for (i = 0; i < def->ncontrollers; i++) { -+ virDomainControllerDefPtr cont = def->controllers[i]; -+ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) -+ ret += virDomainUSBAddressControllerModelToPorts(cont); -+ } -+ -+ for (i = 0; i < def->nhubs; i++) { -+ virDomainHubDefPtr hub = def->hubs[i]; -+ if (hub->type == VIR_DOMAIN_HUB_TYPE_USB) -+ ret += VIR_DOMAIN_USB_HUB_PORTS; -+ } -+ return ret; -+} -+ -+ - /* Try to find a free port on bus @bus. - * - * Returns 0 on success -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index cc36aed..ce94981 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -277,6 +277,8 @@ int - virDomainUSBAddressSetAddHub(virDomainUSBAddressSetPtr addrs, - virDomainHubDefPtr hub) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -+size_t -+virDomainUSBAddressCountAllPorts(virDomainDefPtr def); - void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs); - - int -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index e23bfe3..8cd1ba3 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -108,6 +108,7 @@ virDomainPCIAddressSlotInUse; - virDomainPCIAddressValidate; - virDomainPCIControllerModelToConnectType; - virDomainUSBAddressAssign; -+virDomainUSBAddressCountAllPorts; - virDomainUSBAddressEnsure; - virDomainUSBAddressPortFormat; - virDomainUSBAddressPortFormatBuf; -diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c -index 7499026..787b357 100644 ---- a/src/qemu/qemu_domain_address.c -+++ b/src/qemu/qemu_domain_address.c -@@ -1680,6 +1680,51 @@ qemuDomainAssignUSBPorts(virDomainUSBAddressSetPtr addrs, - - - static int -+qemuDomainAssignUSBPortsCounter(virDomainDeviceInfoPtr info ATTRIBUTE_UNUSED, -+ void *opaque) -+{ -+ struct qemuAssignUSBIteratorInfo *data = opaque; -+ -+ data->count++; -+ return 0; -+} -+ -+ -+static int -+qemuDomainUSBAddressAddHubs(virDomainDefPtr def) -+{ -+ struct qemuAssignUSBIteratorInfo data = { .count = 0 }; -+ virDomainHubDefPtr hub = NULL; -+ size_t available_ports; -+ int ret = -1; -+ -+ available_ports = virDomainUSBAddressCountAllPorts(def); -+ ignore_value(virDomainUSBDeviceDefForeach(def, -+ qemuDomainAssignUSBPortsCounter, -+ &data, -+ false)); -+ VIR_DEBUG("Found %zu USB devices and %zu provided USB ports", -+ data.count, available_ports); -+ -+ /* Add one hub if there are more devices than ports -+ * otherwise it's up to the user to specify more hubs/controllers */ -+ if (data.count > available_ports) { -+ if (VIR_ALLOC(hub) < 0) -+ return -1; -+ hub->type = VIR_DOMAIN_HUB_TYPE_USB; -+ -+ if (VIR_APPEND_ELEMENT(def->hubs, def->nhubs, hub) < 0) -+ goto cleanup; -+ } -+ -+ ret = 0; -+ cleanup: -+ VIR_FREE(hub); -+ return ret; -+} -+ -+ -+static int - qemuDomainAssignUSBAddresses(virDomainDefPtr def, - virDomainObjPtr obj) - { -@@ -1690,6 +1735,9 @@ qemuDomainAssignUSBAddresses(virDomainDefPtr def, - if (!(addrs = virDomainUSBAddressSetCreate())) - goto cleanup; - -+ if (qemuDomainUSBAddressAddHubs(def) < 0) -+ goto cleanup; -+ - if (virDomainUSBAddressSetAddControllers(addrs, def) < 0) - goto cleanup; - -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.args b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.args -new file mode 100644 -index 0000000..12c9691 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.args -@@ -0,0 +1,28 @@ -+LC_ALL=C \ -+PATH=/bin \ -+HOME=/home/test \ -+USER=test \ -+LOGNAME=test \ -+QEMU_AUDIO_DRV=none \ -+/usr/bin/qemu \ -+-name QEMUGuest1 \ -+-S \ -+-M pc \ -+-m 214 \ -+-smp 1 \ -+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -+-nographic \ -+-nodefconfig \ -+-nodefaults \ -+-chardev socket,id=charmonitor,path=/tmp/lib/domain--1-QEMUGuest1/monitor.sock,\ -+server,nowait \ -+-mon chardev=charmonitor,id=monitor,mode=readline \ -+-no-acpi \ -+-boot c \ -+-usb \ -+-device usb-hub,id=hub0,bus=usb.0,port=1 \ -+-device usb-mouse,id=input0,bus=usb.0,port=2 \ -+-device usb-mouse,id=input1,bus=usb.0,port=1.1 \ -+-device usb-mouse,id=input2,bus=usb.0,port=1.2 \ -+-device usb-tablet,id=input3,bus=usb.0,port=1.3 \ -+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.xml -new file mode 100644 -index 0000000..43e0f1f ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-autoadd.xml -@@ -0,0 +1,23 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 1 -+ -+ hvm -+ -+ -+ -+ /usr/bin/qemu -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index e434470..51bab61 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1163,6 +1163,9 @@ mymain(void) - DO_TEST("usb-hub", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); -+ DO_TEST("usb-hub-autoadd", -+ QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, -+ QEMU_CAPS_NODEFCONFIG); - DO_TEST_PARSE_ERROR("usb-hub-conflict", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); --- -2.9.2 - diff --git a/SOURCES/libvirt-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch b/SOURCES/libvirt-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch new file mode 100644 index 0000000..5c2ab6b --- /dev/null +++ b/SOURCES/libvirt-Define-ETHTOOL_-GS-COALESCE-when-building-on-older-kernels.patch @@ -0,0 +1,57 @@ +From f15202cb5a7429a2618cd4ede95064d8874b64ff Mon Sep 17 00:00:00 2001 +Message-Id: +From: Martin Kletzander +Date: Tue, 25 Apr 2017 13:41:21 +0200 +Subject: [PATCH] Define ETHTOOL_[GS]COALESCE when building on older kernels + +https://bugzilla.redhat.com/show_bug.cgi?id=1414627 + +RHEL-only (upstream will have this only when built on kernel that +supports it). + +Signed-off-by: Martin Kletzander +Signed-off-by: Jiri Denemark +--- + src/util/virnetdev.c | 19 ++++++++----------- + 1 file changed, 8 insertions(+), 11 deletions(-) + +diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c +index f14286f62..eb97b705e 100644 +--- a/src/util/virnetdev.c ++++ b/src/util/virnetdev.c +@@ -3082,7 +3082,14 @@ virNetDevGetEthtoolGFeatures(virBitmapPtr bitmap ATTRIBUTE_UNUSED, + # endif + + +-# if HAVE_DECL_ETHTOOL_SCOALESCE && HAVE_DECL_ETHTOOL_GCOALESCE ++/* Workaround for binary distributions building on old kernels */ ++# ifndef ETHTOOL_GCOALESCE ++# define ETHTOOL_GCOALESCE 0x0000000e ++# endif ++# ifndef ETHTOOL_SCOALESCE ++# define ETHTOOL_SCOALESCE 0x0000000f ++# endif ++ + /** + * virNetDevSetCoalesce: + * @ifname: interface name to modify +@@ -3153,16 +3160,6 @@ int virNetDevSetCoalesce(const char *ifname, + VIR_FORCE_CLOSE(fd); + return ret; + } +-# else +-int virNetDevSetCoalesce(const char *ifname, +- virNetDevCoalescePtr coalesce ATTRIBUTE_UNUSED) +-{ +- virReportSystemError(ENOSYS, +- _("Cannot set coalesce info on interface '%s'"), +- ifname); +- return -1; +-} +-# endif + + + /** +-- +2.12.2 + diff --git a/SOURCES/libvirt-Do-not-release-unreserved-address-in-qemuDomainAttachRNGDevice.patch b/SOURCES/libvirt-Do-not-release-unreserved-address-in-qemuDomainAttachRNGDevice.patch new file mode 100644 index 0000000..2f90144 --- /dev/null +++ b/SOURCES/libvirt-Do-not-release-unreserved-address-in-qemuDomainAttachRNGDevice.patch @@ -0,0 +1,46 @@ +From 595b527d46c885352dce5fd9b2e226a1d17c1ef4 Mon Sep 17 00:00:00 2001 +Message-Id: <595b527d46c885352dce5fd9b2e226a1d17c1ef4@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Mon, 22 May 2017 10:50:56 +0200 +Subject: [PATCH] Do not release unreserved address in + qemuDomainAttachRNGDevice +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Only set releaseaddr to true after the address has been +reserved successfully. + +https://bugzilla.redhat.com/show_bug.cgi?id=1452581 + +Reviewed-by: John Ferlan +(cherry picked from commit f25f30aff548636d0c8782d3eaee049c77548dd5) +Signed-off-by: Ján Tomko +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_hotplug.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 6e5678f16..5c3660922 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -2090,7 +2090,6 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, + rng->source.file)) + goto cleanup; + } +- releaseaddr = true; + + if (rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || + rng->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { +@@ -2103,6 +2102,7 @@ qemuDomainAttachRNGDevice(virConnectPtr conn, + !rng->info.addr.ccw.assigned) < 0) + goto cleanup; + } ++ releaseaddr = true; + + if (qemuDomainNamespaceSetupRNG(driver, vm, rng) < 0) + goto cleanup; +-- +2.13.0 + diff --git a/SOURCES/libvirt-Don-t-leak-str-in-virDomainNetDefCoalesceParseXML.patch b/SOURCES/libvirt-Don-t-leak-str-in-virDomainNetDefCoalesceParseXML.patch new file mode 100644 index 0000000..2f1d5d0 --- /dev/null +++ b/SOURCES/libvirt-Don-t-leak-str-in-virDomainNetDefCoalesceParseXML.patch @@ -0,0 +1,31 @@ +From 8405ec82963c74f0505455fa2be35208dafbf907 Mon Sep 17 00:00:00 2001 +Message-Id: <8405ec82963c74f0505455fa2be35208dafbf907@dist-git> +From: Martin Kletzander +Date: Tue, 25 Apr 2017 13:41:19 +0200 +Subject: [PATCH] Don't leak str in virDomainNetDefCoalesceParseXML + +https://bugzilla.redhat.com/show_bug.cgi?id=1414627 + +Signed-off-by: Martin Kletzander +(cherry picked from commit f08e26a19a5ba1cb434627554ee037e5a1b97e83) +Signed-off-by: Martin Kletzander +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index f2801ec84..47022c329 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -6798,6 +6798,7 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, + ret->rx_max_coalesced_frames = tmp; + + cleanup: ++ VIR_FREE(str); + ctxt->node = save; + return ret; + +-- +2.12.2 + diff --git a/SOURCES/libvirt-Fix-logic-in-qemuDomainObjPrivateXMLParseVcpu.patch b/SOURCES/libvirt-Fix-logic-in-qemuDomainObjPrivateXMLParseVcpu.patch deleted file mode 100644 index afcb7f1..0000000 --- a/SOURCES/libvirt-Fix-logic-in-qemuDomainObjPrivateXMLParseVcpu.patch +++ /dev/null @@ -1,65 +0,0 @@ -From a7e224cdad4aae6641fed84cdad621e7fecc8dc7 Mon Sep 17 00:00:00 2001 -Message-Id: -From: "Daniel P. Berrange" -Date: Wed, 24 Aug 2016 16:10:53 -0400 -Subject: [PATCH] Fix logic in qemuDomainObjPrivateXMLParseVcpu - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -The code in qemuDomainObjPrivateXMLParseVcpu for parsing -the 'idstr' string was comparing the overall boolean -result against 0 which was always true - -qemu/qemu_domain.c: In function 'qemuDomainObjPrivateXMLParseVcpu': -qemu/qemu_domain.c:1482:59: error: comparison of constant '0' with boolean expression is always false [-Werror=bool-compare] - if ((idstr && virStrToLong_uip(idstr, NULL, 10, &idx)) < 0 || - ^ - -It was further performing two distinct error checks in -the same conditional and reporting a single error message, -which was misleading in one of the two cases. - -This splits the conditional check into two parts with -distinct error messages and fixes the logic error. - -Fixes the bug in - - commit 5184f398b40a5e0d7d84b86182edcb2b48ab04ba - Author: Peter Krempa - Date: Fri Jul 1 14:56:14 2016 +0200 - - qemu: Store vCPU thread ids in vcpu private data objects - -Signed-off-by: Daniel P. Berrange -(cherry picked from commit ed1fbd7c5ba90ce10cb9a7e35f32a4b4354988aa) ---- - src/qemu/qemu_domain.c | 11 ++++++++--- - 1 file changed, 8 insertions(+), 3 deletions(-) - -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 38225b5..1148b52 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -1510,10 +1510,15 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, - - idstr = virXMLPropString(node, "id"); - -- if ((idstr && virStrToLong_uip(idstr, NULL, 10, &idx)) < 0 || -- !(vcpu = virDomainDefGetVcpu(def, idx))) { -+ if (idstr && -+ (virStrToLong_uip(idstr, NULL, 10, &idx) < 0)) { - virReportError(VIR_ERR_INTERNAL_ERROR, -- _("invalid vcpu index '%s'"), idstr); -+ _("cannot parse vcpu index '%s'"), idstr); -+ goto cleanup; -+ } -+ if (!(vcpu = virDomainDefGetVcpu(def, idx))) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("invalid vcpu index '%u'"), idx); - goto cleanup; - } - --- -2.10.0 - diff --git a/SOURCES/libvirt-Fix-padding-of-encrypted-data.patch b/SOURCES/libvirt-Fix-padding-of-encrypted-data.patch new file mode 100644 index 0000000..024b62b --- /dev/null +++ b/SOURCES/libvirt-Fix-padding-of-encrypted-data.patch @@ -0,0 +1,63 @@ +From 603a58f73e71323294c0d840bbfef4b5d9676e32 Mon Sep 17 00:00:00 2001 +Message-Id: <603a58f73e71323294c0d840bbfef4b5d9676e32@dist-git> +From: "Daniel P. Berrange" +Date: Wed, 3 May 2017 08:52:13 +0200 +Subject: [PATCH] Fix padding of encrypted data + +If we are encoding a block of data that is 16 bytes in length, +we cannot leave it as 16 bytes, we must pad it out to the next +block boundary, 32 bytes. Without this padding, the decoder will +incorrectly treat the last byte of plain text as the padding +length, as it can't distinguish padded from non-padded data. + +The problem exhibited itself when using a 16 byte passphrase +for a LUKS volume + + $ virsh secret-set-value 55806c7d-8e93-456f-829b-607d8c198367 \ + $(echo -n 1234567812345678 | base64) + Secret value set + + $ virsh start demo + error: Failed to start domain demo + error: internal error: process exited while connecting to monitor: >>>>>>>>>>Len 16 + 2017-05-02T10:35:40.016390Z qemu-system-x86_64: -object \ + secret,id=virtio-disk1-luks-secret0,data=SEtNi5vDUeyseMKHwc1c1Q==,\ + keyid=masterKey0,iv=zm7apUB1A6dPcH53VW960Q==,format=base64: \ + Incorrect number of padding bytes (56) found on decrypted data + +Notice how the padding '56' corresponds to the ordinal value of +the character '8'. + +Signed-off-by: Daniel P. Berrange +(cherry picked from commit 71890992daf37ec78b00b4ce873369421dc99731) + +https://bugzilla.redhat.com/show_bug.cgi?id=1447297 +Signed-off-by: Jiri Denemark +--- + src/util/vircrypto.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/src/util/vircrypto.c b/src/util/vircrypto.c +index 8748e1c4e..48b04fc8c 100644 +--- a/src/util/vircrypto.c ++++ b/src/util/vircrypto.c +@@ -152,8 +152,14 @@ virCryptoEncryptDataAESgnutls(gnutls_cipher_algorithm_t gnutls_enc_alg, + uint8_t *ciphertext; + size_t ciphertextlen; + +- /* Allocate a padded buffer, copy in the data */ +- ciphertextlen = VIR_ROUND_UP(datalen, 16); ++ /* Allocate a padded buffer, copy in the data. ++ * ++ * NB, we must *always* have at least 1 byte of ++ * padding - we can't skip it on multiples of ++ * 16, otherwise decoder can't distinguish padded ++ * data from non-padded data. Hence datalen + 1 ++ */ ++ ciphertextlen = VIR_ROUND_UP(datalen + 1, 16); + if (VIR_ALLOC_N(ciphertext, ciphertextlen) < 0) + return -1; + memcpy(ciphertext, data, datalen); +-- +2.12.2 + diff --git a/SOURCES/libvirt-Increase-default-file-handle-limits-for-daemons.patch b/SOURCES/libvirt-Increase-default-file-handle-limits-for-daemons.patch deleted file mode 100644 index f9f8bbf..0000000 --- a/SOURCES/libvirt-Increase-default-file-handle-limits-for-daemons.patch +++ /dev/null @@ -1,81 +0,0 @@ -From a5ceaa8601794b7a60726c7fed5bf29dde15c9b2 Mon Sep 17 00:00:00 2001 -Message-Id: -From: "Daniel P. Berrange" -Date: Thu, 13 Apr 2017 13:36:31 -0400 -Subject: [PATCH] Increase default file handle limits for daemons - -Linux still defaults to a 1024 open file handle limit. This causes -scalability problems for libvirtd / virtlockd / virtlogd on large -hosts which might want > 1024 guest to be running. In fact if each -guest needs > 1 FD, we can't even get to 500 guests. This is not -good enough when we see machines with 100's of physical cores and -TBs of RAM. - -In comparison to other memory requirements of libvirtd & related -daemons, the resource usage associated with open file handles -is essentially line noise. It is thus reasonable to increase the -limits unconditionally for all installs. - -Resolves: https://bugzilla.redhat.com/1442043 (RHEL7.3.z) -Resolves: https://bugzilla.redhat.com/1429551 (RHEL7.4) - -Signed-off-by: Daniel P. Berrange -(cherry picked from commit 27cd76350021d36b9bd8b187ce5c8919659e3806) ---- - daemon/libvirtd.service.in | 7 +++++-- - src/locking/virtlockd.service.in | 4 ++++ - src/logging/virtlogd.service.in | 5 +++++ - 3 files changed, 14 insertions(+), 2 deletions(-) - -diff --git a/daemon/libvirtd.service.in b/daemon/libvirtd.service.in -index bbf27dae9..5f5d35edb 100644 ---- a/daemon/libvirtd.service.in -+++ b/daemon/libvirtd.service.in -@@ -23,8 +23,11 @@ ExecStart=@sbindir@/libvirtd $LIBVIRTD_ARGS - ExecReload=/bin/kill -HUP $MAINPID - KillMode=process - Restart=on-failure --# Override the maximum number of opened files --#LimitNOFILE=2048 -+# At least 1 FD per guest, often 2 (eg qemu monitor + qemu agent). -+# eg if we want to support 4096 guests, we'll typically need 8192 FDs -+# If changing this, also consider virtlogd.service & virtlockd.service -+# limits which are also related to number of guests -+LimitNOFILE=8192 - - [Install] - WantedBy=multi-user.target -diff --git a/src/locking/virtlockd.service.in b/src/locking/virtlockd.service.in -index 57089b046..4907e3290 100644 ---- a/src/locking/virtlockd.service.in -+++ b/src/locking/virtlockd.service.in -@@ -12,6 +12,10 @@ ExecReload=/bin/kill -USR1 $MAINPID - # cause the machine to be fenced (rebooted), so make - # sure we discourage OOM killer - OOMScoreAdjust=-900 -+# Needs to allow for max guests * average disks per guest -+# libvirtd.service written to expect 4096 guests, so if we -+# allow for 4 disks per guest, we get: -+LimitNOFILE=16384 - - [Install] - Also=virtlockd.socket -diff --git a/src/logging/virtlogd.service.in b/src/logging/virtlogd.service.in -index 09e074014..8b67317cb 100644 ---- a/src/logging/virtlogd.service.in -+++ b/src/logging/virtlogd.service.in -@@ -13,6 +13,11 @@ ExecReload=/bin/kill -USR1 $MAINPID - # cause the machine to be fenced (rebooted), so make - # sure we discourage OOM killer - OOMScoreAdjust=-900 -+# Need to have at least one file open per guest (eg QEMU -+# stdio log), but might be more (eg serial console logs) -+# libvirtd.service written to expect 4096 guests, so if we -+# guess at 2 log files per guest here (stdio + 1 serial): -+LimitNOFILE=8192 - - [Install] - Also=virtlogd.socket --- -2.12.2 - diff --git a/SOURCES/libvirt-Introduce-SMM-feature.patch b/SOURCES/libvirt-Introduce-SMM-feature.patch deleted file mode 100644 index f58e3eb..0000000 --- a/SOURCES/libvirt-Introduce-SMM-feature.patch +++ /dev/null @@ -1,384 +0,0 @@ -From b330f5cda86acf70de78d103a7ed5a0e0e3cbacb Mon Sep 17 00:00:00 2001 -Message-Id: -From: Michal Privoznik -Date: Fri, 5 Aug 2016 14:35:25 +0200 -Subject: [PATCH] Introduce SMM feature - -https://bugzilla.redhat.com/show_bug.cgi?id=1304483 - -Since its release of 2.4.0 qemu is able to enable System -Management Module in the firmware, or disable it. We should -expose this capability in the XML. Unfortunately, there's no good -way to determine whether the binary we are talking to supports -it. I mean, if qemu's run with real machine type, the smm -attribute can be seen in 'qom-list /machine' output. But it's not -there when qemu's run with -M none. Therefore we're stuck with -version based check. - -Also, for the RHEL-7.3 I had to adjust the machine-smm-opt test. -In the upstream we already retired QEMU_CAPS_SMP_TOPOLOGY -capability, but not in RHEL yet. - -Signed-off-by: Michal Privoznik -(cherry picked from commit d0e4be9d0297494ba0e23843593f734234ddb08f) -Signed-off-by: Michal Privoznik - - Conflicts: - tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml - tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml - tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml - - QEMU_CAPS_DISPLAY is not backported yet - -Signed-off-by: Michal Privoznik ---- - docs/formatdomain.html.in | 6 +++++ - docs/schemas/domaincommon.rng | 9 +++++++ - src/conf/domain_conf.c | 5 +++- - src/conf/domain_conf.h | 1 + - src/qemu/qemu_capabilities.c | 16 +++++++++++++ - src/qemu/qemu_capabilities.h | 4 ++++ - src/qemu/qemu_command.c | 12 ++++++++++ - tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml | 1 + - tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml | 1 + - .../caps_2.6.0-gicv2.aarch64.xml | 1 + - .../caps_2.6.0-gicv3.aarch64.xml | 1 + - tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 1 + - tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 1 + - .../qemuxml2argv-machine-smm-opt.args | 25 +++++++++++++++++++ - .../qemuxml2argv-machine-smm-opt.xml | 28 ++++++++++++++++++++++ - tests/qemuxml2argvtest.c | 8 +++++++ - 16 files changed, 119 insertions(+), 1 deletion(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.xml - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index f006179..4d4d601 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -1655,6 +1655,12 @@ - values are 2, 3 and host. - Since 1.2.16 - -+
smm
-+
Enable System Management Mode. Possible values are -+ on and off. The default is left -+ for hypervisor to decide. -+ Since 2.1.0 -+
- - -

Time keeping

-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index f17104b..3960a98 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -4286,6 +4286,15 @@ - - - -+ -+ -+ -+ -+ -+ -+ -+ -+ - - - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index abf889a..c02c821 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -137,7 +137,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, - "capabilities", - "pmu", - "vmport", -- "gic") -+ "gic", -+ "smm") - - VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST, - "default", -@@ -16361,6 +16362,7 @@ virDomainDefParseXML(xmlDocPtr xml, - case VIR_DOMAIN_FEATURE_PMU: - case VIR_DOMAIN_FEATURE_PVSPINLOCK: - case VIR_DOMAIN_FEATURE_VMPORT: -+ case VIR_DOMAIN_FEATURE_SMM: - node = ctxt->node; - ctxt->node = nodes[i]; - if ((tmp = virXPathString("string(./@state)", ctxt))) { -@@ -23265,6 +23267,7 @@ virDomainDefFormatInternal(virDomainDefPtr def, - case VIR_DOMAIN_FEATURE_PMU: - case VIR_DOMAIN_FEATURE_PVSPINLOCK: - case VIR_DOMAIN_FEATURE_VMPORT: -+ case VIR_DOMAIN_FEATURE_SMM: - switch ((virTristateSwitch) def->features[i]) { - case VIR_TRISTATE_SWITCH_LAST: - case VIR_TRISTATE_SWITCH_ABSENT: -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 1f75be1..88b0122 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -1598,6 +1598,7 @@ typedef enum { - VIR_DOMAIN_FEATURE_PMU, - VIR_DOMAIN_FEATURE_VMPORT, - VIR_DOMAIN_FEATURE_GIC, -+ VIR_DOMAIN_FEATURE_SMM, - - VIR_DOMAIN_FEATURE_LAST - } virDomainFeature; -diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c -index b35948d..d3964bd 100644 ---- a/src/qemu/qemu_capabilities.c -+++ b/src/qemu/qemu_capabilities.c -@@ -338,6 +338,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, - - "tls-creds-x509", /* 230 */ - "intel-iommu", -+ "smm", - ); - - -@@ -3538,6 +3539,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, - if (qemuCaps->version >= 2003000) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE); - -+ /* smm option is supported from v2.4.0 */ -+ if (qemuCaps->version >= 2004000) -+ virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT); -+ - /* Since 2.4.50 ARM virt machine supports gic-version option */ - if (qemuCaps->version >= 2004050) - virQEMUCapsSet(qemuCaps, QEMU_CAPS_MACH_VIRT_GIC_VERSION); -@@ -4057,6 +4062,17 @@ virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps, - - - bool -+virQEMUCapsSupportsSMM(virQEMUCapsPtr qemuCaps, -+ const virDomainDef *def) -+{ -+ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_MACHINE_SMM_OPT)) -+ return false; -+ -+ return qemuDomainMachineIsQ35(def); -+} -+ -+ -+bool - virQEMUCapsIsMachineSupported(virQEMUCapsPtr qemuCaps, - const char *canonical_machine) - { -diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h -index 379aff0..150d619 100644 ---- a/src/qemu/qemu_capabilities.h -+++ b/src/qemu/qemu_capabilities.h -@@ -371,6 +371,7 @@ typedef enum { - /* 230 */ - QEMU_CAPS_OBJECT_TLS_CREDS_X509, /* -object tls-creds-x509 */ - QEMU_CAPS_DEVICE_INTEL_IOMMU, /* -device intel-iommu */ -+ QEMU_CAPS_MACHINE_SMM_OPT, /* -machine xxx,smm=on/off/auto */ - - QEMU_CAPS_LAST /* this must always be the last item */ - } virQEMUCapsFlags; -@@ -407,6 +408,9 @@ bool virQEMUCapsHasPCIMultiBus(virQEMUCapsPtr qemuCaps, - bool virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps, - const virDomainDef *def); - -+bool virQEMUCapsSupportsSMM(virQEMUCapsPtr qemuCaps, -+ const virDomainDef *def); -+ - char *virQEMUCapsFlagsString(virQEMUCapsPtr qemuCaps); - - const char *virQEMUCapsGetBinary(virQEMUCapsPtr qemuCaps); -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index 1a5c6dc..773f5f3 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -6996,6 +6996,7 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, - } - } else { - virTristateSwitch vmport = def->features[VIR_DOMAIN_FEATURE_VMPORT]; -+ virTristateSwitch smm = def->features[VIR_DOMAIN_FEATURE_SMM]; - - virCommandAddArg(cmd, "-machine"); - virBufferAdd(&buf, def->os.machine, -1); -@@ -7025,6 +7026,17 @@ qemuBuildMachineCommandLine(virCommandPtr cmd, - virTristateSwitchTypeToString(vmport)); - } - -+ if (smm) { -+ if (!virQEMUCapsSupportsSMM(qemuCaps, def)) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("smm is not available with this QEMU binary")); -+ goto cleanup; -+ } -+ -+ virBufferAsprintf(&buf, ",smm=%s", -+ virTristateSwitchTypeToString(smm)); -+ } -+ - if (def->mem.dump_core) { - if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DUMP_GUEST_CORE)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -diff --git a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml -index 98c260c..225019a 100644 ---- a/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.4.0.x86_64.xml -@@ -183,6 +183,7 @@ - - - -+ - 2004000 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml -index 590c8c1..f16f057 100644 ---- a/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.5.0.x86_64.xml -@@ -188,6 +188,7 @@ - - - -+ - 2005000 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml -index aa65733..c57f11f 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml -@@ -157,6 +157,7 @@ - - - -+ - 2005094 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml -index 04d77f7..9798323 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml -@@ -157,6 +157,7 @@ - - - -+ - 2005094 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml -index 120d249..7392551 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml -@@ -151,6 +151,7 @@ - - - -+ - 2005094 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -index 128ac11..766c514 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -@@ -194,6 +194,7 @@ - - - -+ - 2006000 - 0 - -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args b/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args -new file mode 100644 -index 0000000..e49d7e9 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.args -@@ -0,0 +1,25 @@ -+LC_ALL=C \ -+PATH=/bin \ -+HOME=/home/test \ -+USER=test \ -+LOGNAME=test \ -+QEMU_AUDIO_DRV=none \ -+/usr/bin/qemu \ -+-name QEMUGuest1 \ -+-S \ -+-machine q35,accel=tcg,smm=on \ -+-m 214 \ -+-smp 1,sockets=1,cores=1,threads=1 \ -+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -+-nographic \ -+-nodefaults \ -+-monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ -+-no-acpi \ -+-boot c \ -+-device i82801b11-bridge,id=pci.1,bus=pcie.0,addr=0x1e \ -+-device pci-bridge,chassis_nr=2,id=pci.2,bus=pci.1,addr=0x0 \ -+-device virtio-scsi-pci,id=scsi0,bus=pci.2,addr=0x1 \ -+-drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-scsi0-0-0-0 \ -+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ -+drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 \ -+-device virtio-balloon-pci,id=balloon0,bus=pci.2,addr=0x2 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.xml b/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.xml -new file mode 100644 -index 0000000..b964b5e ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-machine-smm-opt.xml -@@ -0,0 +1,28 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219100 -+ 219100 -+ 1 -+ -+ hvm -+ -+ -+ -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+
-+ -+ -+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index f49f9b9..5c26812 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -617,6 +617,14 @@ mymain(void) - QEMU_CAPS_DUMP_GUEST_CORE); - DO_TEST_FAILURE("machine-core-on", NONE); - DO_TEST_FAILURE("machine-core-on", QEMU_CAPS_MACHINE_OPT); -+ DO_TEST("machine-smm-opt", -+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_PCI_BRIDGE, -+ QEMU_CAPS_ICH9_AHCI, -+ QEMU_CAPS_MACHINE_OPT, -+ QEMU_CAPS_MACHINE_SMM_OPT, -+ QEMU_CAPS_SMP_TOPOLOGY, -+ QEMU_CAPS_VIRTIO_SCSI); - DO_TEST("machine-usb-opt", QEMU_CAPS_MACHINE_OPT, - QEMU_CAPS_MACHINE_USB_OPT); - DO_TEST("machine-vmport-opt", QEMU_CAPS_MACHINE_OPT, --- -2.9.2 - diff --git a/SOURCES/libvirt-Introduce-iommu-device.patch b/SOURCES/libvirt-Introduce-iommu-device.patch deleted file mode 100644 index 7aaad98..0000000 --- a/SOURCES/libvirt-Introduce-iommu-device.patch +++ /dev/null @@ -1,536 +0,0 @@ -From aa8079012cc5655cc0e2c55532f8e6b55f1d0a51 Mon Sep 17 00:00:00 2001 -Message-Id: -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Mon, 25 Jul 2016 10:24:56 +0200 -Subject: [PATCH] Introduce device -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -A device with an attribute 'model', with just one model -so far: - - - ... - - - -https://bugzilla.redhat.com/show_bug.cgi?id=1235581 -(cherry picked from commit ea0ed35d6efcba9e79c76d7b57959f553b76224a) -Signed-off-by: Ján Tomko ---- - docs/formatdomain.html.in | 26 +++++++ - docs/schemas/domaincommon.rng | 11 +++ - src/conf/domain_conf.c | 90 +++++++++++++++++++++- - src/conf/domain_conf.h | 16 ++++ - src/libvirt_private.syms | 2 + - src/qemu/qemu_driver.c | 6 ++ - src/qemu/qemu_hotplug.c | 1 + - .../qemuxml2argvdata/qemuxml2argv-intel-iommu.xml | 37 +++++++++ - .../qemuxml2xmlout-intel-iommu.xml | 37 +++++++++ - tests/qemuxml2xmltest.c | 4 + - 10 files changed, 229 insertions(+), 1 deletion(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.xml - create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu.xml - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index b0b2f82..d206f6a 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -6716,6 +6716,32 @@ qemu-kvm -net nic,model=? /dev/null - - - -+

IOMMU devices

-+ -+

-+ The iommu element can be used to add an IOMMU device. -+ Since 2.1.0 -+

-+ -+

-+ Example: -+

-+
-+  ...
-+  <devices>
-+    <iommu model='intel'/>
-+  </devices>
-+  ...
-+
-+
-+
model
-+
-+

-+ Currently only the intel model is supported. -+

-+
-+
-+ -

Security label

- -

-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index 0876daa..f17104b 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -3713,6 +3713,14 @@ - - - -+ -+ -+ -+ intel -+ -+ -+ -+ - - - -@@ -4184,6 +4192,9 @@ - - - -+ -+ -+ - - - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index bc01633..ddeca0d 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -241,7 +241,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, - "shmem", - "tpm", - "panic", -- "memory") -+ "memory", -+ "iommu") - - VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, - "none", -@@ -804,6 +805,9 @@ VIR_ENUM_IMPL(virDomainTPMModel, VIR_DOMAIN_TPM_MODEL_LAST, - VIR_ENUM_IMPL(virDomainTPMBackend, VIR_DOMAIN_TPM_TYPE_LAST, - "passthrough") - -+VIR_ENUM_IMPL(virDomainIOMMUModel, VIR_DOMAIN_IOMMU_MODEL_LAST, -+ "intel") -+ - VIR_ENUM_IMPL(virDomainDiskDiscard, VIR_DOMAIN_DISK_DISCARD_LAST, - "default", - "unmap", -@@ -2364,6 +2368,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) - case VIR_DOMAIN_DEVICE_MEMORY: - virDomainMemoryDefFree(def->data.memory); - break; -+ case VIR_DOMAIN_DEVICE_IOMMU: -+ VIR_FREE(def->data.iommu); -+ break; - case VIR_DOMAIN_DEVICE_LAST: - case VIR_DOMAIN_DEVICE_NONE: - break; -@@ -2610,6 +2617,8 @@ void virDomainDefFree(virDomainDefPtr def) - virDomainPanicDefFree(def->panics[i]); - VIR_FREE(def->panics); - -+ VIR_FREE(def->iommu); -+ - VIR_FREE(def->idmap.uidmap); - VIR_FREE(def->idmap.gidmap); - -@@ -3179,6 +3188,7 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device) - /* The following devices do not contain virDomainDeviceInfo */ - case VIR_DOMAIN_DEVICE_LEASE: - case VIR_DOMAIN_DEVICE_GRAPHICS: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - case VIR_DOMAIN_DEVICE_NONE: - break; -@@ -3540,6 +3550,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, - case VIR_DOMAIN_DEVICE_LAST: - case VIR_DOMAIN_DEVICE_RNG: - case VIR_DOMAIN_DEVICE_MEMORY: -+ case VIR_DOMAIN_DEVICE_IOMMU: - break; - } - #endif -@@ -4635,6 +4646,7 @@ virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_MEMORY: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_LAST: - break; -@@ -13269,6 +13281,39 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, - } - - -+static virDomainIOMMUDefPtr -+virDomainIOMMUDefParseXML(xmlNodePtr node) -+{ -+ virDomainIOMMUDefPtr iommu = NULL, ret = NULL; -+ char *tmp = NULL; -+ int val; -+ -+ if (VIR_ALLOC(iommu) < 0) -+ goto cleanup; -+ -+ if (!(tmp = virXMLPropString(node, "model"))) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("missing model for IOMMU device")); -+ goto cleanup; -+ } -+ -+ if ((val = virDomainIOMMUModelTypeFromString(tmp)) < 0) { -+ virReportError(VIR_ERR_XML_ERROR, _("unknown IOMMU model: %s"), tmp); -+ goto cleanup; -+ } -+ -+ iommu->model = val; -+ -+ ret = iommu; -+ iommu = NULL; -+ -+ cleanup: -+ VIR_FREE(iommu); -+ VIR_FREE(tmp); -+ return ret; -+} -+ -+ - virDomainDeviceDefPtr - virDomainDeviceDefParse(const char *xmlStr, - const virDomainDef *def, -@@ -13410,6 +13455,10 @@ virDomainDeviceDefParse(const char *xmlStr, - if (!(dev->data.memory = virDomainMemoryDefParseXML(node, ctxt, flags))) - goto error; - break; -+ case VIR_DOMAIN_DEVICE_IOMMU: -+ if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node))) -+ goto error; -+ break; - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_LAST: - break; -@@ -17217,6 +17266,21 @@ virDomainDefParseXML(xmlDocPtr xml, - } - VIR_FREE(nodes); - -+ if ((n = virXPathNodeSet("./devices/iommu", ctxt, &nodes)) < 0) -+ goto error; -+ -+ if (n > 1) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("only a single IOMMU device is supported")); -+ goto error; -+ } -+ -+ if (n > 0) { -+ if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0]))) -+ goto error; -+ } -+ VIR_FREE(nodes); -+ - /* analysis of the user namespace mapping */ - if ((n = virXPathNodeSet("./idmap/uid", ctxt, &nodes)) < 0) - goto error; -@@ -18983,6 +19047,23 @@ virDomainDefCheckABIStability(virDomainDefPtr src, - goto error; - } - -+ if (!!src->iommu != !!dst->iommu) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("Target domain IOMMU device count " -+ "does not match source")); -+ goto error; -+ } -+ -+ if (src->iommu && -+ src->iommu->model != dst->iommu->model) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("Target domain IOMMU device model '%s' " -+ "does not match source '%s'"), -+ virDomainIOMMUModelTypeToString(dst->iommu->model), -+ virDomainIOMMUModelTypeToString(src->iommu->model)); -+ goto error; -+ } -+ - /* Coverity is not very happy with this - all dead_error_condition */ - #if !STATIC_ANALYSIS - /* This switch statement is here to trigger compiler warning when adding -@@ -19015,6 +19096,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src, - case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_MEMORY: -+ case VIR_DOMAIN_DEVICE_IOMMU: - break; - } - #endif -@@ -23525,6 +23607,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, - goto error; - } - -+ if (def->iommu) { -+ virBufferAsprintf(buf, "\n", -+ virDomainIOMMUModelTypeToString(def->iommu->model)); -+ } -+ - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - -@@ -24642,6 +24729,7 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: - case VIR_DOMAIN_DEVICE_SHMEM: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Copying definition of '%d' type " -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index f29c4bd..1f75be1 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -151,6 +151,9 @@ typedef virDomainShmemDef *virDomainShmemDefPtr; - typedef struct _virDomainTPMDef virDomainTPMDef; - typedef virDomainTPMDef *virDomainTPMDefPtr; - -+typedef struct _virDomainIOMMUDef virDomainIOMMUDef; -+typedef virDomainIOMMUDef *virDomainIOMMUDefPtr; -+ - /* Flags for the 'type' field in virDomainDeviceDef */ - typedef enum { - VIR_DOMAIN_DEVICE_NONE = 0, -@@ -176,6 +179,7 @@ typedef enum { - VIR_DOMAIN_DEVICE_TPM, - VIR_DOMAIN_DEVICE_PANIC, - VIR_DOMAIN_DEVICE_MEMORY, -+ VIR_DOMAIN_DEVICE_IOMMU, - - VIR_DOMAIN_DEVICE_LAST - } virDomainDeviceType; -@@ -207,6 +211,7 @@ struct _virDomainDeviceDef { - virDomainTPMDefPtr tpm; - virDomainPanicDefPtr panic; - virDomainMemoryDefPtr memory; -+ virDomainIOMMUDefPtr iommu; - } data; - }; - -@@ -2097,6 +2102,15 @@ struct _virDomainKeyWrapDef { - int dea; /* enum virTristateSwitch */ - }; - -+typedef enum { -+ VIR_DOMAIN_IOMMU_MODEL_INTEL, -+ -+ VIR_DOMAIN_IOMMU_MODEL_LAST -+} virDomainIOMMUModel; -+ -+struct _virDomainIOMMUDef { -+ virDomainIOMMUModel model; -+}; - /* - * Guest VM main configuration - * -@@ -2234,6 +2248,7 @@ struct _virDomainDef { - virCPUDefPtr cpu; - virSysinfoDefPtr sysinfo; - virDomainRedirFilterDefPtr redirfilter; -+ virDomainIOMMUDefPtr iommu; - - void *namespaceData; - virDomainXMLNamespace ns; -@@ -2999,6 +3014,7 @@ VIR_ENUM_DECL(virDomainTPMModel) - VIR_ENUM_DECL(virDomainTPMBackend) - VIR_ENUM_DECL(virDomainMemoryModel) - VIR_ENUM_DECL(virDomainMemoryBackingModel) -+VIR_ENUM_DECL(virDomainIOMMUModel) - /* from libvirt.h */ - VIR_ENUM_DECL(virDomainState) - VIR_ENUM_DECL(virDomainNostateReason) -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 8cd1ba3..4dd93d7 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -353,6 +353,8 @@ virDomainHubTypeToString; - virDomainHypervTypeFromString; - virDomainHypervTypeToString; - virDomainInputDefFree; -+virDomainIOMMUModelTypeFromString; -+virDomainIOMMUModelTypeToString; - virDomainIOThreadIDAdd; - virDomainIOThreadIDDefFree; - virDomainIOThreadIDDel; -diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index f1425b7..2d6e5d2 100644 ---- a/src/qemu/qemu_driver.c -+++ b/src/qemu/qemu_driver.c -@@ -7440,6 +7440,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, - case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("live attach of device '%s' is not supported"), -@@ -7531,6 +7532,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("live detach of device '%s' is not supported"), -@@ -7646,6 +7648,7 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn, - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("live update of device '%s' is not supported"), -@@ -7809,6 +7812,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("persistent attach of device '%s' is not supported"), -@@ -7963,6 +7967,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("persistent detach of device '%s' is not supported"), -@@ -8061,6 +8066,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef, - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("persistent update of device '%s' is not supported"), -diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c -index 4a56cad..7a71333 100644 ---- a/src/qemu/qemu_hotplug.c -+++ b/src/qemu/qemu_hotplug.c -@@ -3328,6 +3328,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, - case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -+ case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, - _("don't know how to remove a %s device"), -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.xml -new file mode 100644 -index 0000000..b5b2b51 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu.xml -@@ -0,0 +1,37 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219100 -+ 219100 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+

-+ -+ -+ -+ -+
-+ -+ -+
-+ -+ -+ -+ -+
-+ -+ -+ -+ -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu.xml -new file mode 100644 -index 0000000..b5b2b51 ---- /dev/null -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu.xml -@@ -0,0 +1,37 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219100 -+ 219100 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+
-+ -+ -+ -+ -+
-+ -+ -+
-+ -+ -+ -+ -+
-+ -+ -+ -+ -diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c -index c6ef28c..2112d39 100644 ---- a/tests/qemuxml2xmltest.c -+++ b/tests/qemuxml2xmltest.c -@@ -830,6 +830,10 @@ mymain(void) - DO_TEST("video-qxl-heads"); - DO_TEST("video-qxl-noheads"); - -+ DO_TEST_FULL("intel-iommu", WHEN_ACTIVE, GIC_NONE, -+ QEMU_CAPS_DEVICE_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE); -+ - qemuTestDriverFree(&driver); - - return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; --- -2.9.2 - diff --git a/SOURCES/libvirt-Introduce-secure-attribute-to-os-loader-element.patch b/SOURCES/libvirt-Introduce-secure-attribute-to-os-loader-element.patch deleted file mode 100644 index ba9ba05..0000000 --- a/SOURCES/libvirt-Introduce-secure-attribute-to-os-loader-element.patch +++ /dev/null @@ -1,190 +0,0 @@ -From 8d9b2ba3738c9447c1cdea9ea1b81eee3ffe00f4 Mon Sep 17 00:00:00 2001 -Message-Id: <8d9b2ba3738c9447c1cdea9ea1b81eee3ffe00f4@dist-git> -From: Michal Privoznik -Date: Fri, 5 Aug 2016 14:35:26 +0200 -Subject: [PATCH] Introduce @secure attribute to os loader element - -https://bugzilla.redhat.com/show_bug.cgi?id=1304483 - -This element will control secure boot implemented by some -firmwares. If the firmware used in does support the -feature we must tell it to the underlying hypervisor. However, we -can't know whether loader does support it or not just by looking -at the file. Therefore we have to have an attribute to the -element where users can tell us whether the firmware is secure -boot enabled or not. - -Signed-off-by: Michal Privoznik -(cherry picked from commit 64c24800437ee372d228103291626705892c3ad9) -Signed-off-by: Michal Privoznik ---- - docs/formatdomain.html.in | 7 ++-- - docs/schemas/domaincommon.rng | 8 +++++ - src/conf/domain_conf.c | 14 ++++++++ - src/conf/domain_conf.h | 1 + - .../qemuxml2argv-bios-nvram-secure.xml | 41 ++++++++++++++++++++++ - 5 files changed, 69 insertions(+), 2 deletions(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.xml - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index 4d4d601..c2e261d 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -102,7 +102,7 @@ - ... - <os> - <type>hvm</type> -- <loader readonly='yes' type='rom'>/usr/lib/xen/boot/hvmloader</loader> -+ <loader readonly='yes' secure='no' type='rom'>/usr/lib/xen/boot/hvmloader</loader> - <nvram template='/usr/share/OVMF/OVMF_VARS.fd'>/var/lib/libvirt/nvram/guest_VARS.fd</nvram> - <boot dev='hd'/> - <boot dev='cdrom'/> -@@ -140,7 +140,10 @@ - pflash. It tells the hypervisor where in the guest - memory the file should be mapped. For instance, if the loader - path points to an UEFI image, type should be -- pflash. -+ pflash. Moreover, some firmwares may -+ implement the Secure boot feature. Attribute -+ secure can be used then to control it. -+ Since 2.1.0 -
nvram
-
Some UEFI firmwares may want to use a non-volatile memory to store - some variables. In the host, this is represented as a file and the -diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index 3960a98..497597c 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -260,6 +260,14 @@ - - - -+ -+ -+ yes -+ no -+ -+ -+ -+ - - - rom -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index c02c821..715ca2b 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -15371,9 +15371,11 @@ virDomainLoaderDefParseXML(xmlNodePtr node, - { - int ret = -1; - char *readonly_str = NULL; -+ char *secure_str = NULL; - char *type_str = NULL; - - readonly_str = virXMLPropString(node, "readonly"); -+ secure_str = virXMLPropString(node, "secure"); - type_str = virXMLPropString(node, "type"); - loader->path = (char *) xmlNodeGetContent(node); - -@@ -15384,6 +15386,13 @@ virDomainLoaderDefParseXML(xmlNodePtr node, - goto cleanup; - } - -+ if (secure_str && -+ (loader->secure = virTristateBoolTypeFromString(secure_str)) <= 0) { -+ virReportError(VIR_ERR_XML_DETAIL, -+ _("unknown secure value: %s"), secure_str); -+ goto cleanup; -+ } -+ - if (type_str) { - int type; - if ((type = virDomainLoaderTypeFromString(type_str)) < 0) { -@@ -15397,6 +15406,7 @@ virDomainLoaderDefParseXML(xmlNodePtr node, - ret = 0; - cleanup: - VIR_FREE(readonly_str); -+ VIR_FREE(secure_str); - VIR_FREE(type_str); - return ret; - } -@@ -22512,6 +22522,7 @@ virDomainLoaderDefFormat(virBufferPtr buf, - virDomainLoaderDefPtr loader) - { - const char *readonly = virTristateBoolTypeToString(loader->readonly); -+ const char *secure = virTristateBoolTypeToString(loader->secure); - const char *type = virDomainLoaderTypeToString(loader->type); - - virBufferAddLit(buf, "readonly) - virBufferAsprintf(buf, " readonly='%s'", readonly); - -+ if (loader->secure) -+ virBufferAsprintf(buf, " secure='%s'", secure); -+ - virBufferAsprintf(buf, " type='%s'>", type); - - virBufferEscapeString(buf, "%s\n", loader->path); -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 88b0122..6eed30e 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -1731,6 +1731,7 @@ struct _virDomainLoaderDef { - char *path; - int readonly; /* enum virTristateBool */ - virDomainLoader type; -+ int secure; /* enum virTristateBool */ - char *nvram; /* path to non-volatile RAM */ - char *templt; /* user override of path to master nvram */ - }; -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.xml b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.xml -new file mode 100644 -index 0000000..0ddddfe3 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-bios-nvram-secure.xml -@@ -0,0 +1,41 @@ -+ -+ test-bios -+ 362d1fc1-df7d-193e-5c18-49a71bd1da66 -+ 1048576 -+ 1048576 -+ 1 -+ -+ hvm -+ /usr/share/OVMF/OVMF_CODE.secboot.fd -+ /usr/share/OVMF/OVMF_VARS.fd -+ -+ -+ -+ -+ -+ -+ -+ -+ destroy -+ restart -+ restart -+ -+ /usr/bin/qemu -+ -+ -+ -+
-+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ --- -2.9.2 - diff --git a/SOURCES/libvirt-Introduce-virDomainUSBAddressSet.patch b/SOURCES/libvirt-Introduce-virDomainUSBAddressSet.patch deleted file mode 100644 index 3b93e8c..0000000 --- a/SOURCES/libvirt-Introduce-virDomainUSBAddressSet.patch +++ /dev/null @@ -1,127 +0,0 @@ -From da353cc1db4b13c50c3d79d5053d47a389a86148 Mon Sep 17 00:00:00 2001 -Message-Id: -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:50 +0200 -Subject: [PATCH] Introduce virDomainUSBAddressSet -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -A new type to track USB addresses. - -Every is represented by an -object of type virDomainUSBAddressHub located at buses[i]. - -Each of these hubs has up to 'nports' ports. -If a port is occupied, it has the corresponding bit set in -the 'ports' bitmap, e.g. port 1 would have the 0th bit set. -If there is a hub on this port, then hubs[i] will point -to this hub. - -(cherry picked from commit 82c142b321a10c62aa0a10e3ae9ba603b2d7d155) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - src/conf/domain_addr.c | 42 ++++++++++++++++++++++++++++++++++++++++++ - src/conf/domain_addr.h | 22 ++++++++++++++++++++++ - src/libvirt_private.syms | 2 ++ - 3 files changed, 66 insertions(+) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 741d045..658aad5 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1284,3 +1284,45 @@ virDomainUSBAddressPortFormat(unsigned int *port) - return NULL; - return virBufferContentAndReset(&buf); - } -+ -+ -+virDomainUSBAddressSetPtr -+virDomainUSBAddressSetCreate(void) -+{ -+ virDomainUSBAddressSetPtr addrs; -+ -+ if (VIR_ALLOC(addrs) < 0) -+ return NULL; -+ -+ return addrs; -+} -+ -+ -+static void -+virDomainUSBAddressHubFree(virDomainUSBAddressHubPtr hub) -+{ -+ size_t i; -+ -+ if (!hub) -+ return; -+ -+ for (i = 0; i < hub->nports; i++) -+ virDomainUSBAddressHubFree(hub->ports[i]); -+ virBitmapFree(hub->portmap); -+ VIR_FREE(hub); -+} -+ -+ -+void -+virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs) -+{ -+ size_t i; -+ -+ if (!addrs) -+ return; -+ -+ for (i = 0; i < addrs->nbuses; i++) -+ virDomainUSBAddressHubFree(addrs->buses[i]); -+ VIR_FREE(addrs->buses); -+ VIR_FREE(addrs); -+} -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index cfc74d5..168d3ed 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -249,4 +249,26 @@ char * - virDomainUSBAddressPortFormat(unsigned int *port) - ATTRIBUTE_NONNULL(1); - -+typedef struct _virDomainUSBAddressHub virDomainUSBAddressHub; -+typedef virDomainUSBAddressHub *virDomainUSBAddressHubPtr; -+struct _virDomainUSBAddressHub { -+ /* indexes are shifted by one: -+ * ports[0] represents port 1, because ports are numbered from 1 */ -+ virBitmapPtr portmap; -+ size_t nports; -+ virDomainUSBAddressHubPtr *ports; -+}; -+ -+struct _virDomainUSBAddressSet { -+ /* every is represented -+ * as a hub at buses[i] */ -+ virDomainUSBAddressHubPtr *buses; -+ size_t nbuses; -+}; -+typedef struct _virDomainUSBAddressSet virDomainUSBAddressSet; -+typedef virDomainUSBAddressSet *virDomainUSBAddressSetPtr; -+ -+virDomainUSBAddressSetPtr virDomainUSBAddressSetCreate(void); -+void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs); -+ - #endif /* __DOMAIN_ADDR_H__ */ -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 44b78e0..49f8d6c 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -110,6 +110,8 @@ virDomainPCIControllerModelToConnectType; - virDomainUSBAddressPortFormat; - virDomainUSBAddressPortFormatBuf; - virDomainUSBAddressPortIsValid; -+virDomainUSBAddressSetCreate; -+virDomainUSBAddressSetFree; - virDomainVirtioSerialAddrAssign; - virDomainVirtioSerialAddrAutoAssign; - virDomainVirtioSerialAddrIsComplete; --- -2.9.2 - diff --git a/SOURCES/libvirt-Introduce-virDomainUSBDeviceDefForeach.patch b/SOURCES/libvirt-Introduce-virDomainUSBDeviceDefForeach.patch deleted file mode 100644 index 312cb3d..0000000 --- a/SOURCES/libvirt-Introduce-virDomainUSBDeviceDefForeach.patch +++ /dev/null @@ -1,158 +0,0 @@ -From ad806164d0df731d6ce8b24109abb360584ea64b Mon Sep 17 00:00:00 2001 -Message-Id: -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:47 +0200 -Subject: [PATCH] Introduce virDomainUSBDeviceDefForeach -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -A helper that will execute a callback on every USB device -in the domain definition. - -With an ability to skip USB hubs, since we will want to treat -them differently in some cases. - -(cherry picked from commit 492b3bfda175a846bdbff898607197b0b306d58c) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - src/conf/domain_conf.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++++ - src/conf/domain_conf.h | 7 ++++ - src/libvirt_private.syms | 1 + - 3 files changed, 97 insertions(+) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index bb297f6..e6dc23d 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -24022,6 +24022,95 @@ virDomainSmartcardDefForeach(virDomainDefPtr def, - } - - -+int -+virDomainUSBDeviceDefForeach(virDomainDefPtr def, -+ virDomainUSBDeviceDefIterator iter, -+ void *opaque, -+ bool skipHubs) -+{ -+ size_t i; -+ -+ /* usb-hub */ -+ if (!skipHubs) { -+ for (i = 0; i < def->nhubs; i++) { -+ virDomainHubDefPtr hub = def->hubs[i]; -+ if (hub->type == VIR_DOMAIN_HUB_TYPE_USB) { -+ if (iter(&hub->info, opaque) < 0) -+ return -1; -+ } -+ } -+ } -+ -+ /* usb-host */ -+ for (i = 0; i < def->nhostdevs; i++) { -+ virDomainHostdevDefPtr hostdev = def->hostdevs[i]; -+ if (hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { -+ if (iter(hostdev->info, opaque) < 0) -+ return -1; -+ } -+ } -+ -+ /* usb-storage */ -+ for (i = 0; i < def->ndisks; i++) { -+ virDomainDiskDefPtr disk = def->disks[i]; -+ if (disk->bus == VIR_DOMAIN_DISK_BUS_USB) { -+ if (iter(&disk->info, opaque) < 0) -+ return -1; -+ } -+ } -+ -+ /* TODO: add def->nets here when libvirt starts supporting usb-net */ -+ -+ /* usb-ccid */ -+ for (i = 0; i < def->ncontrollers; i++) { -+ virDomainControllerDefPtr cont = def->controllers[i]; -+ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_CCID) { -+ if (iter(&cont->info, opaque) < 0) -+ return -1; -+ } -+ } -+ -+ /* usb-kbd, usb-mouse, usb-tablet */ -+ for (i = 0; i < def->ninputs; i++) { -+ virDomainInputDefPtr input = def->inputs[i]; -+ -+ if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) { -+ if (iter(&input->info, opaque) < 0) -+ return -1; -+ } -+ } -+ -+ /* usb-serial */ -+ for (i = 0; i < def->nserials; i++) { -+ virDomainChrDefPtr serial = def->serials[i]; -+ if (serial->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_USB) { -+ if (iter(&serial->info, opaque) < 0) -+ return -1; -+ } -+ } -+ -+ /* usb-audio model=usb */ -+ for (i = 0; i < def->nsounds; i++) { -+ virDomainSoundDefPtr sound = def->sounds[i]; -+ if (sound->model == VIR_DOMAIN_SOUND_MODEL_USB) { -+ if (iter(&sound->info, opaque) < 0) -+ return -1; -+ } -+ } -+ -+ /* usb-redir */ -+ for (i = 0; i < def->nredirdevs; i++) { -+ virDomainRedirdevDefPtr redirdev = def->redirdevs[i]; -+ if (redirdev->bus == VIR_DOMAIN_REDIRDEV_BUS_USB) { -+ if (iter(&redirdev->info, opaque) < 0) -+ return -1; -+ } -+ } -+ -+ return 0; -+} -+ -+ - /* Call iter(disk, name, depth, opaque) for each element of disk and - * its backing chain in the pre-populated disk->src.backingStore. - * ignoreOpenFailure determines whether to warn about a chain that -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index e1990dc..f29c4bd 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2884,6 +2884,13 @@ typedef int (*virDomainDiskDefPathIterator)(virDomainDiskDefPtr disk, - size_t depth, - void *opaque); - -+typedef int (*virDomainUSBDeviceDefIterator)(virDomainDeviceInfoPtr info, -+ void *opaque); -+int virDomainUSBDeviceDefForeach(virDomainDefPtr def, -+ virDomainUSBDeviceDefIterator iter, -+ void *opaque, -+ bool skipHubs); -+ - int virDomainDiskDefForeachPath(virDomainDiskDefPtr disk, - bool ignoreOpenFailure, - virDomainDiskDefPathIterator iter, -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 4617f5d..de620a8 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -473,6 +473,7 @@ virDomainTPMBackendTypeToString; - virDomainTPMDefFree; - virDomainTPMModelTypeFromString; - virDomainTPMModelTypeToString; -+virDomainUSBDeviceDefForeach; - virDomainVideoDefaultRAM; - virDomainVideoDefaultType; - virDomainVideoDefFree; --- -2.9.2 - diff --git a/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch b/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch index 38e52a1..b72350b 100644 --- a/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch +++ b/SOURCES/libvirt-RHEL-Add-rhel-machine-types-to-qemuDomainMachineNeedsFDC.patch @@ -1,5 +1,5 @@ -From c6b70e343c1050b9fc497b3e1d8b5190f3889e1e Mon Sep 17 00:00:00 2001 -Message-Id: +From 43caa2e812f3329221b875bbef4f0dcd07f8da05 Mon Sep 17 00:00:00 2001 +Message-Id: <43caa2e812f3329221b875bbef4f0dcd07f8da05@dist-git> From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Mon, 22 Feb 2016 12:51:51 +0100 Subject: [PATCH] RHEL: Add rhel machine types to qemuDomainMachineNeedsFDC @@ -17,10 +17,10 @@ Signed-off-by: Jiri Denemark 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index fd25669..0edcc04 100644 +index 589eb1889..9f165c1da 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c -@@ -4918,6 +4918,9 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def) +@@ -5889,6 +5889,9 @@ qemuDomainMachineNeedsFDC(const virDomainDef *def) STRPREFIX(p, "2.2") || STRPREFIX(p, "2.3")) return false; @@ -31,5 +31,5 @@ index fd25669..0edcc04 100644 } return false; -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch b/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch index f83cc40..362558d 100644 --- a/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch +++ b/SOURCES/libvirt-RHEL-Add-support-for-QMP-I-O-error-reason.patch @@ -1,5 +1,5 @@ -From f45c3ceef34cdc47dbf3b5694769a8282a956983 Mon Sep 17 00:00:00 2001 -Message-Id: +From d2a647fd2d68114875222614d6b098a96c9d16c3 Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiri Denemark Date: Thu, 9 Oct 2014 10:38:39 +0200 Subject: [PATCH] RHEL: Add support for QMP I/O error reason @@ -18,10 +18,10 @@ Signed-off-by: Jiri Denemark 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c -index 5a65203..2890872 100644 +index 6fcf57cd1..405f79fec 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c -@@ -592,7 +592,7 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data) +@@ -646,7 +646,7 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data) { const char *device; const char *action; @@ -30,7 +30,7 @@ index 5a65203..2890872 100644 bool nospc = false; int actionID; -@@ -608,8 +608,14 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data) +@@ -662,8 +662,14 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data) if ((device = virJSONValueObjectGetString(data, "device")) == NULL) VIR_WARN("missing device in disk io error event"); @@ -48,5 +48,5 @@ index 5a65203..2890872 100644 if ((actionID = qemuMonitorIOErrorActionTypeFromString(action)) < 0) { VIR_WARN("unknown disk io error action '%s'", action); -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch b/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch index dacf41d..6007b17 100644 --- a/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch +++ b/SOURCES/libvirt-RHEL-Fix-maxvcpus-output.patch @@ -1,5 +1,5 @@ -From 14ede92edfd80dc9610f92ae6f0d925f2bc2d100 Mon Sep 17 00:00:00 2001 -Message-Id: <14ede92edfd80dc9610f92ae6f0d925f2bc2d100@dist-git> +From 6ce52a680d7799f1a861f98c50581a74b15d51a1 Mon Sep 17 00:00:00 2001 +Message-Id: <6ce52a680d7799f1a861f98c50581a74b15d51a1@dist-git> From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 17 Sep 2014 19:00:58 +0200 Subject: [PATCH] RHEL: Fix maxvcpus output @@ -19,21 +19,21 @@ Signed-off-by: Jiri Denemark 1 file changed, 5 insertions(+) diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c -index fed5be7..dfdc543 100644 +index 02b9fc8eb..20d3a004b 100644 --- a/src/util/virhostcpu.c +++ b/src/util/virhostcpu.c -@@ -1311,6 +1311,11 @@ virHostCPUGetKVMMaxVCPUs(void) +@@ -1166,6 +1166,11 @@ virHostCPUGetKVMMaxVCPUs(void) return -1; } +/* Ignore KVM_CAP_MAX_VCPUS on RHEL - the recommended maximum + * is treated as a hard limit. + */ -+#undef KVM_CAP_MAX_VCPUS ++# undef KVM_CAP_MAX_VCPUS + - #ifdef KVM_CAP_MAX_VCPUS + # ifdef KVM_CAP_MAX_VCPUS /* at first try KVM_CAP_MAX_VCPUS to determine the maximum count */ if ((ret = ioctl(fd, KVM_CHECK_EXTENSION, KVM_CAP_MAX_VCPUS)) > 0) -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch b/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch index d0fff31..897b338 100644 --- a/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch +++ b/SOURCES/libvirt-RHEL-Hack-around-changed-Broadwell-Haswell-CPUs.patch @@ -1,5 +1,5 @@ -From 0c8ec3bc6be11a4043f6f4bb697fbca4bc46e448 Mon Sep 17 00:00:00 2001 -Message-Id: <0c8ec3bc6be11a4043f6f4bb697fbca4bc46e448@dist-git> +From 26d33ed184f16a57b412360e4e75dbbcb9807c76 Mon Sep 17 00:00:00 2001 +Message-Id: <26d33ed184f16a57b412360e4e75dbbcb9807c76@dist-git> From: Jiri Denemark Date: Fri, 27 Mar 2015 12:48:40 +0100 Subject: [PATCH] RHEL: Hack around changed Broadwell/Haswell CPUs @@ -11,7 +11,7 @@ removing rtm and hle features from the corresponding CPU models for new machine types. Then they reverted this and introduced new *-noTSX models instead. However, the original fix was backported to RHEL. -This patch makes sue Broadwell and Haswell will always contain rtm and +This patch makes sure Broadwell and Haswell will always contain rtm and hle features regardless on RHEL version or machine type used. https://bugzilla.redhat.com/show_bug.cgi?id=1199446 @@ -20,52 +20,58 @@ Signed-off-by: Jiri Denemark --- src/qemu/qemu_command.c | 21 +++++++++++++++++++++ .../qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args | 2 +- - .../qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args | 2 +- - 3 files changed, 23 insertions(+), 2 deletions(-) + .../qemuxml2argv-cpu-host-model-cmt.args | 3 ++- + .../qemuxml2argv-cpu-tsc-frequency.args | 2 +- + 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index 71e9e63..5b2f041 100644 +index 64d2d7105..1a2984e56 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c -@@ -6251,6 +6251,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, - virCPUCompareResult cmp; - const char *preferred; +@@ -6768,6 +6768,8 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, + size_t i; virCapsPtr caps = NULL; + virCPUDefPtr cpu = def->cpu; + bool hle = false; + bool rtm = false; - bool compareAgainstHost = ((def->virtType == VIR_DOMAIN_VIRT_KVM || - def->cpu->mode != VIR_CPU_MODE_CUSTOM) && - def->cpu->mode != VIR_CPU_MODE_HOST_PASSTHROUGH); -@@ -6404,8 +6406,27 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, - else - sign = '+'; -+ if (STREQ("rtm", featCpu->features[i].name)) -+ rtm = true; -+ if (STREQ("hle", featCpu->features[i].name)) -+ hle = true; + if (!(caps = virQEMUDriverGetCapabilities(driver, false))) + goto cleanup; +@@ -6822,6 +6824,11 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, + virBufferAsprintf(buf, ",vendor=%s", cpu->vendor_id); + + for (i = 0; i < cpu->nfeatures; i++) { ++ if (STREQ("rtm", cpu->features[i].name)) ++ rtm = true; ++ if (STREQ("hle", cpu->features[i].name)) ++ hle = true; + - virBufferAsprintf(buf, ",%c%s", sign, featCpu->features[i].name); + switch ((virCPUFeaturePolicy) cpu->features[i].policy) { + case VIR_CPU_FEATURE_FORCE: + case VIR_CPU_FEATURE_REQUIRE: +@@ -6845,6 +6852,20 @@ qemuBuildCpuModelArgStr(virQEMUDriverPtr driver, } -+ -+ /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU -+ * models which lack rtm and hle features when used with some machine -+ * types. Let's make sure Broadwell and Haswell will always have these -+ * features. But only if the features were not explicitly mentioned in -+ * the guest CPU definition. -+ */ -+ if (STREQ_NULLABLE(featCpu->model, "Broadwell") || -+ STREQ_NULLABLE(featCpu->model, "Haswell")) { -+ if (!rtm) -+ virBufferAddLit(buf, ",+rtm"); -+ if (!hle) -+ virBufferAddLit(buf, ",+hle"); -+ } } ++ /* Some versions of qemu-kvm in RHEL provide Broadwell and Haswell CPU ++ * models which lack rtm and hle features when used with some machine ++ * types. Let's make sure Broadwell and Haswell will always have these ++ * features. But only if the features were not explicitly mentioned in ++ * the guest CPU definition. ++ */ ++ if (STREQ_NULLABLE(cpu->model, "Broadwell") || ++ STREQ_NULLABLE(cpu->model, "Haswell")) { ++ if (!rtm) ++ virBufferAddLit(buf, ",+rtm"); ++ if (!hle) ++ virBufferAddLit(buf, ",+hle"); ++ } ++ ret = 0; + cleanup: + virObjectUnref(caps); diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args -index d00a619..29cf688 100644 +index ef0e68b14..2e74a6703 100644 --- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell.args @@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \ @@ -75,21 +81,35 @@ index d00a619..29cf688 100644 --cpu Haswell \ +-cpu Haswell,+rtm,+hle \ -m 214 \ - -smp 6 \ + -smp 6,sockets=6,cores=1,threads=1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args -index d00a619..29cf688 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-Haswell3.args -@@ -8,7 +8,7 @@ QEMU_AUDIO_DRV=none \ - -name QEMUGuest1 \ +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args +index 7ae4ac5ad..e02f996ee 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args +@@ -9,7 +9,8 @@ QEMU_AUDIO_DRV=none \ -S \ -M pc \ ---cpu Haswell \ -+-cpu Haswell,+rtm,+hle \ + -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\ +-+smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm \ +++smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,+rtm,\ +++hle \ + -m 214 \ + -smp 6,sockets=6,cores=1,threads=1 \ + -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args +index 50223fab2..cd9a3ef16 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-tsc-frequency.args +@@ -10,7 +10,7 @@ QEMU_AUDIO_DRV=none \ + -M pc \ + -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\ + +smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+lahf_lm,\ +-+invtsc,tsc-frequency=3504000000 \ +++invtsc,+rtm,+hle,tsc-frequency=3504000000 \ -m 214 \ - -smp 6 \ + -smp 1,sockets=1,cores=1,threads=1 \ -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch b/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch index f949dc4..8347599 100644 --- a/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch +++ b/SOURCES/libvirt-RHEL-Support-virtio-disk-hotplug-in-JSON-mode.patch @@ -1,5 +1,5 @@ -From 167dc5464595cf08f3134514d722b75b0e20d4ac Mon Sep 17 00:00:00 2001 -Message-Id: <167dc5464595cf08f3134514d722b75b0e20d4ac@dist-git> +From 2d1d83a1d3eeb7cf98972c461842f333f900c1e2 Mon Sep 17 00:00:00 2001 +Message-Id: <2d1d83a1d3eeb7cf98972c461842f333f900c1e2@dist-git> From: Jiri Denemark Date: Tue, 5 Apr 2016 09:14:09 +0200 Subject: [PATCH] RHEL: Support virtio disk hotplug in JSON mode @@ -53,14 +53,14 @@ Conflicts: src/qemu/qemu_monitor.c | 12 +++-- src/qemu/qemu_monitor_json.c | 106 +++++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_monitor_json.h | 6 +++ - tests/qemuhotplugtest.c | 83 ++++++++++++++++++++++++++++++++- - 4 files changed, 201 insertions(+), 6 deletions(-) + tests/qemuhotplugtest.c | 92 ++++++++++++++++++++++++++++++++++++- + 4 files changed, 210 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c -index 1e27470..1d3d98a 100644 +index 8bc00bc1e..488d761fb 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c -@@ -2704,8 +2704,10 @@ qemuMonitorDriveDel(qemuMonitorPtr mon, +@@ -3073,8 +3073,10 @@ qemuMonitorDriveDel(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); @@ -73,7 +73,7 @@ index 1e27470..1d3d98a 100644 } -@@ -2808,8 +2810,10 @@ qemuMonitorAddDrive(qemuMonitorPtr mon, +@@ -3195,8 +3197,10 @@ qemuMonitorAddDrive(qemuMonitorPtr mon, QEMU_CHECK_MONITOR(mon); @@ -87,10 +87,10 @@ index 1e27470..1d3d98a 100644 diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c -index 35e38a9..5a65203 100644 +index 2010657e3..6fcf57cd1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c -@@ -3677,6 +3677,112 @@ int qemuMonitorJSONDelObject(qemuMonitorPtr mon, +@@ -3807,6 +3807,112 @@ int qemuMonitorJSONDelObject(qemuMonitorPtr mon, } @@ -139,7 +139,7 @@ index 35e38a9..5a65203 100644 + /* there won't be a direct replacement for drive_add in QMP */ + ret = qemuMonitorTextAddDrive(mon, drivestr); + -+cleanup: ++ cleanup: + virJSONValueFree(args); + virJSONValueFree(cmd); + virJSONValueFree(reply); @@ -194,7 +194,7 @@ index 35e38a9..5a65203 100644 + } + } + -+cleanup: ++ cleanup: + virJSONValueFree(cmd); + virJSONValueFree(reply); + return ret; @@ -204,10 +204,10 @@ index 35e38a9..5a65203 100644 const char *alias, const char *passphrase) diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h -index 4e6f2bc..c573ca2 100644 +index fb697033c..696aaeffc 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h -@@ -229,6 +229,12 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon, +@@ -233,6 +233,12 @@ int qemuMonitorJSONAddObject(qemuMonitorPtr mon, int qemuMonitorJSONDelObject(qemuMonitorPtr mon, const char *objalias); @@ -221,10 +221,10 @@ index 4e6f2bc..c573ca2 100644 const char *alias, const char *passphrase); diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c -index ae57c0a..5f6b838 100644 +index cdeb3f1bf..2e1afeea9 100644 --- a/tests/qemuhotplugtest.c +++ b/tests/qemuhotplugtest.c -@@ -417,6 +417,14 @@ mymain(void) +@@ -658,6 +658,14 @@ mymain(void) " }" \ "}\r\n" @@ -239,127 +239,127 @@ index ae57c0a..5f6b838 100644 DO_TEST_UPDATE("graphics-spice", "graphics-spice-nochange", false, false, NULL); DO_TEST_UPDATE("graphics-spice-timeout", "graphics-spice-timeout-nochange", false, false, "set_password", QMP_OK, "expire_password", QMP_OK); -@@ -437,67 +445,135 @@ mymain(void) +@@ -678,67 +686,135 @@ mymain(void) "chardev-remove", QMP_OK); - DO_TEST_ATTACH("hotplug-base-live", "disk-virtio", false, true, + DO_TEST_ATTACH("base-live", "disk-virtio", false, true, + "__com.redhat_drive_add", QMP_NOT_FOUND, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-live", "disk-virtio", false, false, + DO_TEST_DETACH("base-live", "disk-virtio", false, false, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); -+ DO_TEST_ATTACH("hotplug-base-live", "disk-virtio", false, true, ++ DO_TEST_ATTACH("base-live", "disk-virtio", false, true, + "__com.redhat_drive_add", QMP_OK, + "device_add", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-virtio", false, false, ++ DO_TEST_DETACH("base-live", "disk-virtio", false, false, + "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_OK); + - DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-virtio", false, true, + DO_TEST_ATTACH_EVENT("base-live", "disk-virtio", false, true, + "__com.redhat_drive_add", QMP_NOT_FOUND, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-live", "disk-virtio", true, true, + DO_TEST_DETACH("base-live", "disk-virtio", true, true, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); - DO_TEST_DETACH("hotplug-base-live", "disk-virtio", false, false, + DO_TEST_DETACH("base-live", "disk-virtio", false, false, "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); -+ DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-virtio", false, true, ++ DO_TEST_ATTACH_EVENT("base-live", "disk-virtio", false, true, + "__com.redhat_drive_add", QMP_OK, + "device_add", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-virtio", true, true, ++ DO_TEST_DETACH("base-live", "disk-virtio", true, true, + "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-virtio", false, false, ++ DO_TEST_DETACH("base-live", "disk-virtio", false, false, + "device_del", QMP_DEVICE_DELETED("virtio-disk4") QMP_OK, + "__com.redhat_drive_del", QMP_OK); + - DO_TEST_ATTACH("hotplug-base-live", "disk-usb", false, true, + DO_TEST_ATTACH("base-live", "disk-usb", false, true, + "__com.redhat_drive_add", QMP_NOT_FOUND, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-live", "disk-usb", false, false, + DO_TEST_DETACH("base-live", "disk-usb", false, false, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); -+ DO_TEST_ATTACH("hotplug-base-live", "disk-usb", false, true, ++ DO_TEST_ATTACH("base-live", "disk-usb", false, true, + "__com.redhat_drive_add", QMP_OK, + "device_add", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-usb", false, false, ++ DO_TEST_DETACH("base-live", "disk-usb", false, false, + "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_OK); + - DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-usb", false, true, + DO_TEST_ATTACH_EVENT("base-live", "disk-usb", false, true, + "__com.redhat_drive_add", QMP_NOT_FOUND, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-live", "disk-usb", true, true, + DO_TEST_DETACH("base-live", "disk-usb", true, true, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); - DO_TEST_DETACH("hotplug-base-live", "disk-usb", false, false, + DO_TEST_DETACH("base-live", "disk-usb", false, false, "device_del", QMP_DEVICE_DELETED("usb-disk16") QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); -+ DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-usb", false, true, ++ DO_TEST_ATTACH_EVENT("base-live", "disk-usb", false, true, + "__com.redhat_drive_add", QMP_OK, + "device_add", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-usb", true, true, ++ DO_TEST_DETACH("base-live", "disk-usb", true, true, + "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-usb", false, false, ++ DO_TEST_DETACH("base-live", "disk-usb", false, false, + "device_del", QMP_DEVICE_DELETED("usb-disk16") QMP_OK, + "__com.redhat_drive_del", QMP_OK); + - DO_TEST_ATTACH("hotplug-base-live", "disk-scsi", false, true, + DO_TEST_ATTACH("base-live", "disk-scsi", false, true, + "__com.redhat_drive_add", QMP_NOT_FOUND, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-live", "disk-scsi", false, false, + DO_TEST_DETACH("base-live", "disk-scsi", false, false, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); -+ DO_TEST_ATTACH("hotplug-base-live", "disk-scsi", false, true, ++ DO_TEST_ATTACH("base-live", "disk-scsi", false, true, + "__com.redhat_drive_add", QMP_OK, + "device_add", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-scsi", false, false, ++ DO_TEST_DETACH("base-live", "disk-scsi", false, false, + "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_OK); + - DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-scsi", false, true, + DO_TEST_ATTACH_EVENT("base-live", "disk-scsi", false, true, + "__com.redhat_drive_add", QMP_NOT_FOUND, "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-live", "disk-scsi", true, true, + DO_TEST_DETACH("base-live", "disk-scsi", true, true, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); - DO_TEST_DETACH("hotplug-base-live", "disk-scsi", false, false, + DO_TEST_DETACH("base-live", "disk-scsi", false, false, "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); -+ DO_TEST_ATTACH_EVENT("hotplug-base-live", "disk-scsi", false, true, ++ DO_TEST_ATTACH_EVENT("base-live", "disk-scsi", false, true, + "__com.redhat_drive_add", QMP_OK, + "device_add", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-scsi", true, true, ++ DO_TEST_DETACH("base-live", "disk-scsi", true, true, + "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "disk-scsi", false, false, ++ DO_TEST_DETACH("base-live", "disk-scsi", false, false, + "device_del", QMP_DEVICE_DELETED("scsi0-0-0-5") QMP_OK, + "__com.redhat_drive_del", QMP_OK); + - DO_TEST_ATTACH("hotplug-base-without-scsi-controller-live", "disk-scsi-2", false, true, + DO_TEST_ATTACH("base-without-scsi-controller-live", "disk-scsi-2", false, true, /* Four controllers added */ "device_add", QMP_OK, "device_add", QMP_OK, @@ -370,13 +370,13 @@ index ae57c0a..5f6b838 100644 + "__com.redhat_drive_add", QMP_NOT_FOUND, + "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-with-scsi-controller-live", "disk-scsi-2", false, false, + DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", false, false, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); - DO_TEST_ATTACH_EVENT("hotplug-base-without-scsi-controller-live", "disk-scsi-2", false, true, -@@ -506,14 +582,17 @@ mymain(void) + DO_TEST_ATTACH_EVENT("base-without-scsi-controller-live", "disk-scsi-2", false, true, +@@ -747,14 +823,17 @@ mymain(void) "device_add", QMP_OK, "device_add", QMP_OK, "device_add", QMP_OK, @@ -385,16 +385,64 @@ index ae57c0a..5f6b838 100644 + "__com.redhat_drive_add", QMP_NOT_FOUND, + "human-monitor-command", HMP("OK\\r\\n"), "device_add", QMP_OK); - DO_TEST_DETACH("hotplug-base-with-scsi-controller-live", "disk-scsi-2", true, true, + DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", true, true, "device_del", QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); - DO_TEST_DETACH("hotplug-base-with-scsi-controller-live", "disk-scsi-2", false, false, + DO_TEST_DETACH("base-with-scsi-controller-live", "disk-scsi-2", false, false, "device_del", QMP_DEVICE_DELETED("scsi3-0-5-7") QMP_OK, + "__com.redhat_drive_del", QMP_NOT_FOUND, "human-monitor-command", HMP("")); - DO_TEST_ATTACH("hotplug-base-live", "qemu-agent", false, true, + DO_TEST_ATTACH("base-live", "qemu-agent", false, true, +@@ -765,38 +844,47 @@ mymain(void) + "chardev-remove", QMP_OK); + + DO_TEST_ATTACH("base-ccw-live", "ccw-virtio", false, true, ++ "__com.redhat_drive_add", QMP_NOT_FOUND, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + DO_TEST_DETACH("base-ccw-live", "ccw-virtio", false, false, + "device_del", QMP_OK, ++ "__com.redhat_drive_del", QMP_NOT_FOUND, + "human-monitor-command", HMP("")); + + DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, true, ++ "__com.redhat_drive_add", QMP_NOT_FOUND, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + + DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2", false, false, + "device_del", QMP_OK, ++ "__com.redhat_drive_del", QMP_NOT_FOUND, + "human-monitor-command", HMP("")); + + DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true, ++ "__com.redhat_drive_add", QMP_NOT_FOUND, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + + DO_TEST_DETACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, false, + "device_del", QMP_OK, ++ "__com.redhat_drive_del", QMP_NOT_FOUND, + "human-monitor-command", HMP("")); + + /* Attach a second device, then detach the first one. Then attach the first one again. */ + DO_TEST_ATTACH("base-ccw-live-with-ccw-virtio", "ccw-virtio-2-explicit", false, true, ++ "__com.redhat_drive_add", QMP_NOT_FOUND, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + + DO_TEST_DETACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-explicit", false, true, + "device_del", QMP_OK, ++ "__com.redhat_drive_del", QMP_NOT_FOUND, + "human-monitor-command", HMP("")); + + DO_TEST_ATTACH("base-ccw-live-with-2-ccw-virtio", "ccw-virtio-1-reverse", false, false, ++ "__com.redhat_drive_add", QMP_NOT_FOUND, + "human-monitor-command", HMP("OK\\r\\n"), + "device_add", QMP_OK); + -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-docs-Introduce-subsite-xsl.patch b/SOURCES/libvirt-RHEL-docs-Introduce-subsite-xsl.patch deleted file mode 100644 index be16ec1..0000000 --- a/SOURCES/libvirt-RHEL-docs-Introduce-subsite-xsl.patch +++ /dev/null @@ -1,55 +0,0 @@ -From f51f13a7e9de2b5c235a4c231138fa73d67a49b8 Mon Aug 8 13:14:18 2016 -Message-Id: -From: Michal Privoznik -Date: Mon, 8 Aug 2016 13:08:51 +0200 -Subject: [PATCH] RHEL: docs: Introduce subsite.xsl - -https://bugzilla.redhat.com/show_bug.cgi?id=1365004 - -RHEL only - -The file was not being distributed (now fixed in both upstream -and downstream). However, since we are building on the top of -release that is still missing the file copy it from upstream. - -Signed-off-by: Michal Privoznik ---- - docs/subsite.xsl | 25 +++++++++++++++++++++++++ - 1 file changed, 25 insertions(+) - create mode 100644 docs/subsite.xsl - -diff --git b/docs/subsite.xsl a/docs/subsite.xsl -new file mode 100644 -index 0000000..108d0d8 ---- /dev/null -+++ a/docs/subsite.xsl -@@ -0,0 +1,25 @@ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ --- -2.8.4 - - diff --git a/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch b/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch index 2fb442d..11db783 100644 --- a/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch +++ b/SOURCES/libvirt-RHEL-qemu-Add-ability-to-set-sgio-values-for-hostdev.patch @@ -1,5 +1,5 @@ -From 4b78773be04078d281419b629e58b00f7e6aac26 Mon Sep 17 00:00:00 2001 -Message-Id: <4b78773be04078d281419b629e58b00f7e6aac26@dist-git> +From 5ed5c2acfb240683c3b1d7ec2e63b3c2571d707f Mon Sep 17 00:00:00 2001 +Message-Id: <5ed5c2acfb240683c3b1d7ec2e63b3c2571d707f@dist-git> From: John Ferlan Date: Thu, 9 Jul 2015 08:28:57 -0400 Subject: [PATCH] RHEL: qemu: Add ability to set sgio values for hostdev @@ -18,10 +18,10 @@ Signed-off-by: Jiri Denemark 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c -index 6dfa738..1d5b0ae 100644 +index 3b33e37bb..9137a69f8 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c -@@ -1379,6 +1379,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) +@@ -1458,6 +1458,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) virDomainDiskDefPtr disk = NULL; virDomainHostdevDefPtr hostdev = NULL; char *sysfs_path = NULL; @@ -29,7 +29,7 @@ index 6dfa738..1d5b0ae 100644 const char *path = NULL; int val = -1; int ret = -1; -@@ -1400,14 +1401,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) +@@ -1479,14 +1480,10 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) if (!qemuIsSharedHostdev(hostdev)) return 0; @@ -46,7 +46,7 @@ index 6dfa738..1d5b0ae 100644 } else { return 0; } -@@ -1416,7 +1413,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) +@@ -1495,7 +1492,11 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) goto cleanup; /* By default, filter the SG_IO commands, i.e. set unpriv_sgio to 0. */ @@ -59,7 +59,7 @@ index 6dfa738..1d5b0ae 100644 /* Do not do anything if unpriv_sgio is not supported by the kernel and the * whitelist is enabled. But if requesting unfiltered access, always call -@@ -1429,6 +1430,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) +@@ -1508,6 +1509,7 @@ qemuSetUnprivSGIO(virDomainDeviceDefPtr dev) ret = 0; cleanup: @@ -68,5 +68,5 @@ index 6dfa738..1d5b0ae 100644 return ret; } -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch b/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch index c00903f..6d23430 100644 --- a/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch +++ b/SOURCES/libvirt-RHEL-qemu-Add-check-for-unpriv-sgio-for-SCSI-generic-host-device.patch @@ -1,5 +1,5 @@ -From 47da3da96575632cc166a3e1265e4753dc9a85e8 Mon Sep 17 00:00:00 2001 -Message-Id: <47da3da96575632cc166a3e1265e4753dc9a85e8@dist-git> +From d331ff38d1f088b7cbdaec27b57ebbb81b3ff3d0 Mon Sep 17 00:00:00 2001 +Message-Id: From: John Ferlan Date: Thu, 9 Jul 2015 08:28:58 -0400 Subject: [PATCH] RHEL: qemu: Add check for unpriv sgio for SCSI generic host @@ -22,10 +22,10 @@ Signed-off-by: Jiri Denemark 1 file changed, 15 insertions(+) diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c -index 1d5b0ae..49e8e8b 100644 +index 9137a69f8..7324c9c41 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c -@@ -1219,6 +1219,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, +@@ -1298,6 +1298,8 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, { char *dev_path = NULL; char *key = NULL; @@ -34,7 +34,7 @@ index 1d5b0ae..49e8e8b 100644 int ret = -1; if (!qemuIsSharedHostdev(hostdev)) -@@ -1227,6 +1229,19 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, +@@ -1306,6 +1308,19 @@ qemuAddSharedHostdev(virQEMUDriverPtr driver, if (!(dev_path = qemuGetHostdevPath(hostdev))) goto cleanup; @@ -55,5 +55,5 @@ index 1d5b0ae..49e8e8b 100644 goto cleanup; -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch b/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch index ebf9028..3611f76 100644 --- a/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch +++ b/SOURCES/libvirt-RHEL-qemu-Support-vhost-user-multiqueue-with-QEMU-2.3.patch @@ -1,5 +1,5 @@ -From 000869de9fabb90082dd1577610a04b545cdbf77 Mon Sep 17 00:00:00 2001 -Message-Id: <000869de9fabb90082dd1577610a04b545cdbf77@dist-git> +From 8e998fbb777e15718145899a60cd3d65accf68c9 Mon Sep 17 00:00:00 2001 +Message-Id: <8e998fbb777e15718145899a60cd3d65accf68c9@dist-git> From: Martin Kletzander Date: Mon, 23 Nov 2015 12:46:36 +0100 Subject: [PATCH] RHEL: qemu: Support vhost-user-multiqueue with QEMU 2.3 @@ -16,10 +16,10 @@ Signed-off-by: Jiri Denemark 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c -index 206133d..9f1c0e1 100644 +index 629fc8a9b..83ebcd020 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c -@@ -3529,8 +3529,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, +@@ -4548,8 +4548,11 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_AARCH64_OFF); /* vhost-user supports multi-queue from v2.4.0 onwards, @@ -32,7 +32,7 @@ index 206133d..9f1c0e1 100644 + if (qemuCaps->version >= 2003000) virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOSTUSER_MULTIQUEUE); - /* Since 2.4.50 ARM virt machine supports gic-version option */ + /* smm option is supported from v2.4.0 */ -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch b/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch index 934ac6c..b03fb90 100644 --- a/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch +++ b/SOURCES/libvirt-RHEL-qemu-support-relative-backing-for-RHEL-7.0.z-qemu.patch @@ -1,5 +1,5 @@ -From 2c48579454f7cd49500cb03ae23973c6880ea5ea Mon Sep 17 00:00:00 2001 -Message-Id: <2c48579454f7cd49500cb03ae23973c6880ea5ea@dist-git> +From e57574f1c3a506267da6676a0036bc35dbd923b3 Mon Sep 17 00:00:00 2001 +Message-Id: From: Eric Blake Date: Tue, 7 Oct 2014 17:06:17 -0600 Subject: [PATCH] RHEL: qemu: support relative backing for RHEL 7.0.z qemu @@ -25,17 +25,17 @@ Signed-off-by: Jiri Denemark 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c -index 28d5321..206133d 100644 +index b1245ad5d..629fc8a9b 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c -@@ -1464,6 +1464,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = { +@@ -1480,6 +1480,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = { { "add-fd", QEMU_CAPS_ADD_FD }, { "nbd-server-start", QEMU_CAPS_NBD_SERVER }, { "change-backing-file", QEMU_CAPS_CHANGE_BACKING_FILE }, + { "__com.redhat_change-backing-file", QEMU_CAPS_CHANGE_BACKING_FILE }, { "rtc-reset-reinjection", QEMU_CAPS_RTC_RESET_REINJECTION }, { "migrate-incoming", QEMU_CAPS_INCOMING_DEFER }, - }; + { "query-hotpluggable-cpus", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS }, -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-RHEL-qemuxml2argvtest-Properly-reset-host-CPU-arch.patch b/SOURCES/libvirt-RHEL-qemuxml2argvtest-Properly-reset-host-CPU-arch.patch deleted file mode 100644 index 09b07b3..0000000 --- a/SOURCES/libvirt-RHEL-qemuxml2argvtest-Properly-reset-host-CPU-arch.patch +++ /dev/null @@ -1,37 +0,0 @@ -From eb83a2ac219b229580faaae38422b7129076b70a Mon Sep 17 00:00:00 2001 -Message-Id: -From: Jiri Denemark -Date: Thu, 4 May 2017 10:41:43 +0200 -Subject: [PATCH] RHEL: qemuxml2argvtest: Properly reset host CPU arch - -RHEL-only, upstream reworked the way host CPUs and architectures are -set. - -driver.caps->host.cpu->arch and cpuDefault point to the same structure -and the line did not really do anything leaving the host CPU arch set to -VIR_ARCH_AARCH64. Without this fix qemuxml2argvtest would segfault after -the following patch. - -https://bugzilla.redhat.com/show_bug.cgi?id=1447612 - -Signed-off-by: Jiri Denemark ---- - tests/qemuxml2argvtest.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index dc5580e02..cbf785e1b 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1956,7 +1956,7 @@ mymain(void) - DO_TEST_FAILURE("aarch64-kvm-32-on-64", - QEMU_CAPS_NODEFCONFIG, QEMU_CAPS_DEVICE_VIRTIO_MMIO, - QEMU_CAPS_KVM); -- driver.caps->host.cpu->arch = cpuDefault->arch; -+ driver.caps->host.cpu->arch = VIR_ARCH_X86_64; - - DO_TEST("kvm-pit-device", QEMU_CAPS_KVM_PIT_TICK_POLICY); - DO_TEST("kvm-pit-delay", QEMU_CAPS_NO_KVM_PIT); --- -2.12.2 - diff --git a/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch b/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch index 63c0036..14cd198 100644 --- a/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch +++ b/SOURCES/libvirt-RHEL-screenshot-Implement-multiple-screen-support.patch @@ -1,5 +1,5 @@ -From 9e5ccc797249afe0c44232b6b0d2cae4ff7d8d21 Mon Sep 17 00:00:00 2001 -Message-Id: <9e5ccc797249afe0c44232b6b0d2cae4ff7d8d21@dist-git> +From 647ae3f777d7b2b20e6e0caa4603c0b162cca9ec Mon Sep 17 00:00:00 2001 +Message-Id: <647ae3f777d7b2b20e6e0caa4603c0b162cca9ec@dist-git> From: Michal Privoznik Date: Fri, 26 Aug 2011 16:41:17 +0800 Subject: [PATCH] RHEL: screenshot: Implement multiple screen support @@ -34,10 +34,10 @@ Conflicts: 5 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index 0507be8..7bdf329 100644 +index 3cc4f4d66..3f3eca440 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c -@@ -3768,6 +3768,8 @@ qemuDomainScreenshot(virDomainPtr dom, +@@ -3791,6 +3791,8 @@ qemuDomainScreenshot(virDomainPtr dom, char *ret = NULL; bool unlink_tmp = false; virQEMUDriverConfigPtr cfg = NULL; @@ -46,7 +46,7 @@ index 0507be8..7bdf329 100644 virCheckFlags(0, NULL); -@@ -3789,12 +3791,15 @@ qemuDomainScreenshot(virDomainPtr dom, +@@ -3812,12 +3814,15 @@ qemuDomainScreenshot(virDomainPtr dom, goto endjob; } @@ -68,9 +68,9 @@ index 0507be8..7bdf329 100644 goto endjob; } -@@ -3809,8 +3814,11 @@ qemuDomainScreenshot(virDomainPtr dom, +@@ -3832,8 +3837,11 @@ qemuDomainScreenshot(virDomainPtr dom, - virSecurityManagerSetSavedStateLabel(qemu_driver->securityManager, vm->def, tmp); + qemuSecuritySetSavedStateLabel(driver->securityManager, vm->def, tmp); + if (video_index) + video_id = vm->def->videos[video_index]->info.alias; @@ -82,10 +82,10 @@ index 0507be8..7bdf329 100644 goto endjob; } diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c -index 098e654..1e27470 100644 +index a4fa6eca6..8bc00bc1e 100644 --- a/src/qemu/qemu_monitor.c +++ b/src/qemu/qemu_monitor.c -@@ -3022,12 +3022,22 @@ qemuMonitorSendKey(qemuMonitorPtr mon, +@@ -3409,12 +3409,22 @@ qemuMonitorSendKey(qemuMonitorPtr mon, int qemuMonitorScreendump(qemuMonitorPtr mon, @@ -111,10 +111,10 @@ index 098e654..1e27470 100644 return qemuMonitorJSONScreendump(mon, file); else diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h -index cb4cca8..6e4e09d 100644 +index 91ab9057e..c1506b0fc 100644 --- a/src/qemu/qemu_monitor.h +++ b/src/qemu/qemu_monitor.h -@@ -759,7 +759,8 @@ int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, +@@ -876,7 +876,8 @@ int qemuMonitorArbitraryCommand(qemuMonitorPtr mon, int qemuMonitorInjectNMI(qemuMonitorPtr mon); int qemuMonitorScreendump(qemuMonitorPtr mon, @@ -125,10 +125,10 @@ index cb4cca8..6e4e09d 100644 int qemuMonitorSendKey(qemuMonitorPtr mon, unsigned int holdtime, diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c -index bb426dc..35e38a9 100644 +index aeb777d37..2010657e3 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c -@@ -4155,6 +4155,30 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, +@@ -4262,6 +4262,30 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, return ret; } @@ -160,10 +160,10 @@ index bb426dc..35e38a9 100644 const char *file) { diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h -index 37a739e..4e6f2bc 100644 +index d090d5709..fb697033c 100644 --- a/src/qemu/qemu_monitor_json.h +++ b/src/qemu/qemu_monitor_json.h -@@ -287,6 +287,10 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, +@@ -291,6 +291,10 @@ int qemuMonitorJSONSendKey(qemuMonitorPtr mon, unsigned int *keycodes, unsigned int nkeycodes); @@ -175,5 +175,5 @@ index 37a739e..4e6f2bc 100644 const char *file); -- -2.9.0 +2.12.2 diff --git a/SOURCES/libvirt-Remove-pointless-check-for-ret-in-virDomainNetDefCoalesceParseXML.patch b/SOURCES/libvirt-Remove-pointless-check-for-ret-in-virDomainNetDefCoalesceParseXML.patch new file mode 100644 index 0000000..b45264f --- /dev/null +++ b/SOURCES/libvirt-Remove-pointless-check-for-ret-in-virDomainNetDefCoalesceParseXML.patch @@ -0,0 +1,36 @@ +From 25fbc5c619a4277086b0bce0e3a55dd4099d4ab2 Mon Sep 17 00:00:00 2001 +Message-Id: <25fbc5c619a4277086b0bce0e3a55dd4099d4ab2@dist-git> +From: Martin Kletzander +Date: Tue, 25 Apr 2017 13:41:20 +0200 +Subject: [PATCH] Remove pointless check for !ret in + virDomainNetDefCoalesceParseXML + +https://bugzilla.redhat.com/show_bug.cgi?id=1414627 + +It was left there after removing a macro it was part of in first +version or so. Now it will always be NULL. + +Signed-off-by: Martin Kletzander +(cherry picked from commit b2763f189c5b306a685021b4fede9e2cee8528de) +Signed-off-by: Martin Kletzander +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 47022c329..2d5d00cf2 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -6776,7 +6776,7 @@ virDomainNetDefCoalesceParseXML(xmlNodePtr node, + if (!str) + goto cleanup; + +- if (!ret && VIR_ALLOC(ret) < 0) ++ if (VIR_ALLOC(ret) < 0) + goto cleanup; + + if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) { +-- +2.12.2 + diff --git a/SOURCES/libvirt-Reserve-existing-USB-addresses.patch b/SOURCES/libvirt-Reserve-existing-USB-addresses.patch deleted file mode 100644 index 6a26e8b..0000000 --- a/SOURCES/libvirt-Reserve-existing-USB-addresses.patch +++ /dev/null @@ -1,232 +0,0 @@ -From 5749f8cb78cea11e1247fdcd6108fc632c38a3bc Mon Sep 17 00:00:00 2001 -Message-Id: <5749f8cb78cea11e1247fdcd6108fc632c38a3bc@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:53 +0200 -Subject: [PATCH] Reserve existing USB addresses -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Check if they fit on the USB controllers the domain has, -and error out if two devices try to use the same address. - -(cherry picked from commit ddd31fd7dce3ffaf07d31502c57e1ca940f454fa) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - src/conf/domain_addr.c | 42 ++++++++++++++++++++++ - src/conf/domain_addr.h | 4 +++ - src/libvirt_private.syms | 1 + - src/qemu/qemu_domain.c | 1 + - src/qemu/qemu_domain.h | 1 + - src/qemu/qemu_domain_address.c | 38 +++++++++++++++++++- - .../qemuxml2argv-usb-hub-conflict.xml | 22 ++++++++++++ - tests/qemuxml2argvtest.c | 3 ++ - 8 files changed, 111 insertions(+), 1 deletion(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-hub-conflict.xml - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index ad20fef..bbac399 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1562,3 +1562,45 @@ virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, - } - return 0; - } -+ -+ -+int -+virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, -+ void *data) -+{ -+ virDomainUSBAddressSetPtr addrs = data; -+ virDomainUSBAddressHubPtr targetHub = NULL; -+ char *portStr = NULL; -+ int ret = -1; -+ int targetPort; -+ -+ if (info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) -+ return 0; -+ -+ if (!virDomainUSBAddressPortIsValid(info->addr.usb.port)) -+ return 0; -+ -+ portStr = virDomainUSBAddressPortFormat(info->addr.usb.port); -+ if (!portStr) -+ goto cleanup; -+ VIR_DEBUG("Reserving USB address bus=%u port=%s", info->addr.usb.bus, portStr); -+ -+ if (!(targetHub = virDomainUSBAddressFindPort(addrs, info, &targetPort, -+ portStr))) -+ goto cleanup; -+ -+ if (virBitmapIsBitSet(targetHub->portmap, targetPort)) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("Duplicate USB address bus %u port %s"), -+ info->addr.usb.bus, portStr); -+ goto cleanup; -+ } -+ -+ ignore_value(virBitmapSetBit(targetHub->portmap, targetPort)); -+ -+ ret = 0; -+ -+ cleanup: -+ VIR_FREE(portStr); -+ return ret; -+} -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index 2bd4a0d..a24d216 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -275,4 +275,8 @@ int virDomainUSBAddressSetAddControllers(virDomainUSBAddressSetPtr addrs, - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - void virDomainUSBAddressSetFree(virDomainUSBAddressSetPtr addrs); - -+int -+virDomainUSBAddressReserve(virDomainDeviceInfoPtr info, -+ void *data) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - #endif /* __DOMAIN_ADDR_H__ */ -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index f0fed8e..f66ccf5 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -110,6 +110,7 @@ virDomainPCIControllerModelToConnectType; - virDomainUSBAddressPortFormat; - virDomainUSBAddressPortFormatBuf; - virDomainUSBAddressPortIsValid; -+virDomainUSBAddressReserve; - virDomainUSBAddressSetAddControllers; - virDomainUSBAddressSetCreate; - virDomainUSBAddressSetFree; -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 5b4d7a3..8b0f847 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -1244,6 +1244,7 @@ qemuDomainObjPrivateFree(void *data) - virDomainPCIAddressSetFree(priv->pciaddrs); - virDomainCCWAddressSetFree(priv->ccwaddrs); - virDomainVirtioSerialAddrSetFree(priv->vioserialaddrs); -+ virDomainUSBAddressSetFree(priv->usbaddrs); - virDomainChrSourceDefFree(priv->monConfig); - qemuDomainObjFreeJob(priv); - VIR_FREE(priv->vcpupids); -diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h -index c87dcc7..b71a28d 100644 ---- a/src/qemu/qemu_domain.h -+++ b/src/qemu/qemu_domain.h -@@ -190,6 +190,7 @@ struct _qemuDomainObjPrivate { - virDomainPCIAddressSetPtr pciaddrs; - virDomainCCWAddressSetPtr ccwaddrs; - virDomainVirtioSerialAddrSetPtr vioserialaddrs; -+ virDomainUSBAddressSetPtr usbaddrs; - - virQEMUCapsPtr qemuCaps; - char *lockState; -diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c -index ee44d45..f66b2f0 100644 ---- a/src/qemu/qemu_domain_address.c -+++ b/src/qemu/qemu_domain_address.c -@@ -1622,11 +1622,44 @@ qemuDomainAssignPCIAddresses(virDomainDefPtr def, - } - - -+static int -+qemuDomainAssignUSBAddresses(virDomainDefPtr def, -+ virDomainObjPtr obj) -+{ -+ int ret = -1; -+ virDomainUSBAddressSetPtr addrs = NULL; -+ qemuDomainObjPrivatePtr priv = NULL; -+ -+ if (!(addrs = virDomainUSBAddressSetCreate())) -+ goto cleanup; -+ -+ if (virDomainUSBAddressSetAddControllers(addrs, def) < 0) -+ goto cleanup; -+ -+ if (virDomainUSBDeviceDefForeach(def, virDomainUSBAddressReserve, addrs, -+ true) < 0) -+ goto cleanup; -+ -+ VIR_DEBUG("Existing USB addresses have been reserved"); -+ -+ if (obj && obj->privateData) { -+ priv = obj->privateData; -+ priv->usbaddrs = addrs; -+ addrs = NULL; -+ } -+ ret = 0; -+ -+ cleanup: -+ virDomainUSBAddressSetFree(addrs); -+ return ret; -+} -+ -+ - int - qemuDomainAssignAddresses(virDomainDefPtr def, - virQEMUCapsPtr qemuCaps, - virDomainObjPtr obj, -- bool newDomain ATTRIBUTE_UNUSED) -+ bool newDomain) - { - if (qemuDomainAssignVirtioSerialAddresses(def, obj) < 0) - return -1; -@@ -1642,6 +1675,9 @@ qemuDomainAssignAddresses(virDomainDefPtr def, - if (qemuDomainAssignPCIAddresses(def, qemuCaps, obj) < 0) - return -1; - -+ if (newDomain && qemuDomainAssignUSBAddresses(def, obj) < 0) -+ return -1; -+ - return 0; - } - -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-conflict.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-conflict.xml -new file mode 100644 -index 0000000..9a48ba0 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-conflict.xml -@@ -0,0 +1,22 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 1 -+ -+ hvm -+ -+ -+ -+ /usr/bin/qemu -+ -+ -+ -+
-+ -+ -+
-+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index 4389e24..9c18989 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1159,6 +1159,9 @@ mymain(void) - DO_TEST("usb-hub", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); -+ DO_TEST_PARSE_ERROR("usb-hub-conflict", -+ QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, -+ QEMU_CAPS_NODEFCONFIG); - DO_TEST("usb-port-missing", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); --- -2.9.2 - diff --git a/SOURCES/libvirt-Revert-admin-Fix-the-default-uri-for-session-daemon-to-libvirtd-session.patch b/SOURCES/libvirt-Revert-admin-Fix-the-default-uri-for-session-daemon-to-libvirtd-session.patch deleted file mode 100644 index 5795199..0000000 --- a/SOURCES/libvirt-Revert-admin-Fix-the-default-uri-for-session-daemon-to-libvirtd-session.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 03832c723800e942e67bdc15595844b07422c147 Mon Sep 17 00:00:00 2001 -Message-Id: <03832c723800e942e67bdc15595844b07422c147@dist-git> -From: Erik Skultety -Date: Tue, 16 Aug 2016 13:06:01 +0200 -Subject: [PATCH] Revert "admin: Fix the default uri for session daemon to - libvirtd:///session" - -The problem is, that the patch fixed the issue in its own way because the -original upstream commit 30ce2f0e (which was an incorrect upstream fix anyway) -was dependent on commit f5da0d18 which wasn't backported, thus causing -conflicts. However, it turned out that f5da0d18 had to be backported -eventually, therefore the issue with session daemon uri for virt-admin can be -fixed by a proper backport of upstream commit 9e5e7f3a (that fixes 30ce2f0e in -upstream). - -https://bugzilla.redhat.com/show_bug.cgi?id=1367269 -Signed-off-by: Erik Skultety ---- - src/libvirt-admin.c | 8 ++------ - 1 file changed, 2 insertions(+), 6 deletions(-) - -diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c -index fb2f7b8..f07cb10 100644 ---- a/src/libvirt-admin.c -+++ b/src/libvirt-admin.c -@@ -181,13 +181,9 @@ virAdmGetDefaultURI(virConfPtr conf) - /* Since we can't probe connecting via any hypervisor driver as libvirt - * does, if no explicit URI was given and neither the environment - * variable, nor the configuration parameter had previously been set, -- * we set the default admin server URI to 'libvirtd:///system' or -- * 'libvirtd:///session' depending on the process's EUID. -+ * we set the default admin server URI to 'libvirtd://system'. - */ -- if (geteuid() == 0) -- uristr = "libvirtd:///system"; -- else -- uristr = "libvirtd:///session"; -+ uristr = "libvirtd:///system"; - } - - return uristr; --- -2.9.2 - diff --git a/SOURCES/libvirt-Revert-qemu-propagate-bridge-MTU-into-qemu-host_mtu-option.patch b/SOURCES/libvirt-Revert-qemu-propagate-bridge-MTU-into-qemu-host_mtu-option.patch new file mode 100644 index 0000000..644df32 --- /dev/null +++ b/SOURCES/libvirt-Revert-qemu-propagate-bridge-MTU-into-qemu-host_mtu-option.patch @@ -0,0 +1,204 @@ +From b36260c361f9d8a854c4d5e9c7309aed7cb99834 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Laine Stump +Date: Tue, 23 May 2017 13:02:42 -0400 +Subject: [PATCH] Revert "qemu: propagate bridge MTU into qemu "host_mtu" + option" + +This reverts commit 2841e675. + +It turns out that adding the host_mtu field to the PCI capabilities in +the guest bumps the length of PCI capabilities beyond the 32 byte +boundary, so the virtio-net device gets 64 bytes of ioport space +instead of 32, which offsets the address of all the other following +devices. Migration doesn't work very well when the location and length +of PCI capabilities of devices is changed between source and +destination. + +This means that we need to make sure that the absence/presence of +host_mtu on the qemu commandline always matches between source and +destination, which means that we need to make setting of host_mtu an +opt-in thing (it can't happen automatically when the bridge being used +has a non-default MTU, which is what commit 2841e675 implemented). + +I do want to re-implement this feature with an +setting, but probably won't backport that to any stable branches, so +I'm first reverting the original commit, and that revert can be pushed +to the few releases that have been made since the original (3.1.0 - +3.3.0) + +Resolves: https://bugzilla.redhat.com/1449346 +(cherry picked from commit 77780a29edace958a1f931d3281b962be4f5290e) + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_command.c | 32 ++++++++++---------------------- + src/qemu/qemu_command.h | 3 +-- + src/qemu/qemu_hotplug.c | 5 ++--- + src/qemu/qemu_interface.c | 5 ++--- + src/qemu/qemu_interface.h | 3 +-- + 5 files changed, 16 insertions(+), 32 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 30feef1de..4d3a3d8ca 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -3633,8 +3633,7 @@ qemuBuildNicDevStr(virDomainDefPtr def, + int vlan, + unsigned int bootindex, + size_t vhostfdSize, +- virQEMUCapsPtr qemuCaps, +- unsigned int mtu) ++ virQEMUCapsPtr qemuCaps) + { + virBuffer buf = VIR_BUFFER_INITIALIZER; + const char *nic = net->model; +@@ -3758,23 +3757,13 @@ qemuBuildNicDevStr(virDomainDefPtr def, + virBufferAsprintf(&buf, ",rx_queue_size=%u", net->driver.virtio.rx_queue_size); + } + +- if (usingVirtio && mtu) { +- if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) { +- +- virBufferAsprintf(&buf, ",host_mtu=%u", mtu); +- +- } else { +- /* log an error if mtu was requested specifically for this +- * interface, otherwise, if it's just what was reported by +- * the attached network, ignore it. +- */ +- if (net->mtu) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +- _("setting MTU is not supported with " +- "this QEMU binary")); +- goto error; +- } ++ if (usingVirtio && net->mtu) { ++ if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_NET_HOST_MTU)) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", ++ _("setting MTU is not supported with this QEMU binary")); ++ goto error; + } ++ virBufferAsprintf(&buf, ",host_mtu=%u", net->mtu); + } + + if (vlan == -1) +@@ -8275,7 +8264,7 @@ qemuBuildVhostuserCommandLine(virQEMUDriverPtr driver, + VIR_FREE(netdev); + + if (!(nic = qemuBuildNicDevStr(def, net, -1, bootindex, +- queues, qemuCaps, net->mtu))) { ++ queues, qemuCaps))) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Error generating NIC -device string")); + goto error; +@@ -8321,7 +8310,6 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, + virDomainNetType actualType = virDomainNetGetActualType(net); + virNetDevBandwidthPtr actualBandwidth; + size_t i; +- unsigned int mtu = net->mtu; + + + if (!bootindex) +@@ -8376,7 +8364,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, + memset(tapfd, -1, tapfdSize * sizeof(tapfd[0])); + + if (qemuInterfaceBridgeConnect(def, driver, net, +- tapfd, &tapfdSize, &mtu) < 0) ++ tapfd, &tapfdSize) < 0) + goto cleanup; + break; + +@@ -8556,7 +8544,7 @@ qemuBuildInterfaceCommandLine(virQEMUDriverPtr driver, + } + if (qemuDomainSupportsNicdev(def, net)) { + if (!(nic = qemuBuildNicDevStr(def, net, vlan, bootindex, +- vhostfdSize, qemuCaps, mtu))) ++ vhostfdSize, qemuCaps))) + goto cleanup; + virCommandAddArgList(cmd, "-device", nic, NULL); + } else { +diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h +index 7da92c8c9..09cb00ee9 100644 +--- a/src/qemu/qemu_command.h ++++ b/src/qemu/qemu_command.h +@@ -101,8 +101,7 @@ char *qemuBuildNicDevStr(virDomainDefPtr def, + int vlan, + unsigned int bootindex, + size_t vhostfdSize, +- virQEMUCapsPtr qemuCaps, +- unsigned int mtu); ++ virQEMUCapsPtr qemuCaps); + + char *qemuDeviceDriveHostAlias(virDomainDiskDefPtr disk); + +diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c +index 5c3660922..cdeb0617a 100644 +--- a/src/qemu/qemu_hotplug.c ++++ b/src/qemu/qemu_hotplug.c +@@ -968,7 +968,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + bool charDevPlugged = false; + bool netdevPlugged = false; + bool hostPlugged = false; +- unsigned int mtu = net->mtu; + + /* preallocate new slot for device */ + if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) +@@ -1025,7 +1024,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + goto cleanup; + memset(vhostfd, -1, sizeof(*vhostfd) * vhostfdSize); + if (qemuInterfaceBridgeConnect(vm->def, driver, net, +- tapfd, &tapfdSize, &mtu) < 0) ++ tapfd, &tapfdSize) < 0) + goto cleanup; + iface_connected = true; + if (qemuInterfaceOpenVhostNet(vm->def, net, priv->qemuCaps, +@@ -1239,7 +1238,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, + VIR_FORCE_CLOSE(vhostfd[i]); + + if (!(nicstr = qemuBuildNicDevStr(vm->def, net, vlan, 0, +- queueSize, priv->qemuCaps, mtu))) ++ queueSize, priv->qemuCaps))) + goto try_remove; + + qemuDomainObjEnterMonitor(driver, vm); +diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c +index c643b76ec..e11d69c3e 100644 +--- a/src/qemu/qemu_interface.c ++++ b/src/qemu/qemu_interface.c +@@ -503,8 +503,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, + virQEMUDriverPtr driver, + virDomainNetDefPtr net, + int *tapfd, +- size_t *tapfdSize, +- unsigned int *mtu) ++ size_t *tapfdSize) + { + const char *brname; + int ret = -1; +@@ -545,7 +544,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, + def->uuid, tunpath, tapfd, *tapfdSize, + virDomainNetGetActualVirtPortProfile(net), + virDomainNetGetActualVlan(net), +- net->coalesce, net->mtu, mtu, ++ net->coalesce, 0, NULL, + tap_create_flags) < 0) { + virDomainAuditNetDevice(def, net, tunpath, false); + goto cleanup; +diff --git a/src/qemu/qemu_interface.h b/src/qemu/qemu_interface.h +index ba74ac2cf..a7faa0b3d 100644 +--- a/src/qemu/qemu_interface.h ++++ b/src/qemu/qemu_interface.h +@@ -51,8 +51,7 @@ int qemuInterfaceBridgeConnect(virDomainDefPtr def, + virQEMUDriverPtr driver, + virDomainNetDefPtr net, + int *tapfd, +- size_t *tapfdSize, +- unsigned int *mtu) ++ size_t *tapfdSize) + ATTRIBUTE_NONNULL(2); + + int qemuInterfaceOpenVhostNet(virDomainDefPtr def, +-- +2.13.0 + diff --git a/SOURCES/libvirt-Set-coalesce-settings-for-domain-interfaces.patch b/SOURCES/libvirt-Set-coalesce-settings-for-domain-interfaces.patch new file mode 100644 index 0000000..745263f --- /dev/null +++ b/SOURCES/libvirt-Set-coalesce-settings-for-domain-interfaces.patch @@ -0,0 +1,142 @@ +From 7fadd91380ce1000f3aa5b6e5c4b928f883fbb33 Mon Sep 17 00:00:00 2001 +Message-Id: <7fadd91380ce1000f3aa5b6e5c4b928f883fbb33@dist-git> +From: Martin Kletzander +Date: Tue, 25 Apr 2017 13:41:17 +0200 +Subject: [PATCH] Set coalesce settings for domain interfaces + +This patch makes use of the virNetDevSetCoalesce() function to make +appropriate settings effective for devices that support them. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1414627 + +Signed-off-by: Martin Kletzander +(cherry picked from commit fcef44728dff9cb708d00d17f5e0b44aa513f27b) +Signed-off-by: Martin Kletzander +Signed-off-by: Jiri Denemark +--- + src/bhyve/bhyve_command.c | 2 +- + src/network/bridge_driver.c | 2 +- + src/qemu/qemu_interface.c | 2 +- + src/uml/uml_conf.c | 2 +- + src/util/virnetdevtap.c | 5 +++++ + src/util/virnetdevtap.h | 2 ++ + tests/bhyvexml2argvmock.c | 1 + + 7 files changed, 12 insertions(+), 4 deletions(-) + +diff --git a/src/bhyve/bhyve_command.c b/src/bhyve/bhyve_command.c +index e0528ed77..e9c072b9f 100644 +--- a/src/bhyve/bhyve_command.c ++++ b/src/bhyve/bhyve_command.c +@@ -100,7 +100,7 @@ bhyveBuildNetArgStr(virConnectPtr conn, + def->uuid, NULL, NULL, 0, + virDomainNetGetActualVirtPortProfile(net), + virDomainNetGetActualVlan(net), +- 0, NULL, ++ NULL, 0, NULL, + VIR_NETDEV_TAP_CREATE_IFUP | VIR_NETDEV_TAP_CREATE_PERSIST) < 0) { + goto cleanup; + } +diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c +index 41bce794a..b0026ab17 100644 +--- a/src/network/bridge_driver.c ++++ b/src/network/bridge_driver.c +@@ -2315,7 +2315,7 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, + if (virNetDevTapCreateInBridgePort(network->def->bridge, + &macTapIfName, &network->def->mac, + NULL, NULL, &tapfd, 1, NULL, NULL, +- network->def->mtu, NULL, ++ NULL, network->def->mtu, NULL, + VIR_NETDEV_TAP_CREATE_USE_MAC_FOR_BRIDGE | + VIR_NETDEV_TAP_CREATE_IFUP | + VIR_NETDEV_TAP_CREATE_PERSIST) < 0) { +diff --git a/src/qemu/qemu_interface.c b/src/qemu/qemu_interface.c +index c5dca60f1..2057ac929 100644 +--- a/src/qemu/qemu_interface.c ++++ b/src/qemu/qemu_interface.c +@@ -545,7 +545,7 @@ qemuInterfaceBridgeConnect(virDomainDefPtr def, + def->uuid, tunpath, tapfd, *tapfdSize, + virDomainNetGetActualVirtPortProfile(net), + virDomainNetGetActualVlan(net), +- net->mtu, mtu, ++ net->coalesce, net->mtu, mtu, + tap_create_flags) < 0) { + virDomainAuditNetDevice(def, net, tunpath, false); + goto cleanup; +diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c +index 871653c5a..bdef78324 100644 +--- a/src/uml/uml_conf.c ++++ b/src/uml/uml_conf.c +@@ -125,7 +125,7 @@ umlConnectTapDevice(virDomainDefPtr vm, + vm->uuid, net->backend.tap, &tapfd, 1, + virDomainNetGetActualVirtPortProfile(net), + virDomainNetGetActualVlan(net), +- 0, NULL, ++ NULL, 0, NULL, + VIR_NETDEV_TAP_CREATE_IFUP | + VIR_NETDEV_TAP_CREATE_PERSIST) < 0) { + if (template_ifname) +diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c +index 93002b929..c8dacfe27 100644 +--- a/src/util/virnetdevtap.c ++++ b/src/util/virnetdevtap.c +@@ -584,6 +584,7 @@ virNetDevTapAttachBridge(const char *tapname, + * @tapfd: array of file descriptor return value for the new tap device + * @tapfdSize: number of file descriptors in @tapfd + * @virtPortProfile: bridge/port specific configuration ++ * @coalesce: optional coalesce parameters + * @mtu: requested MTU for port (or 0 for "default") + * @actualMTU: MTU actually set for port (after accounting for bridge's MTU) + * @flags: OR of virNetDevTapCreateFlags: +@@ -616,6 +617,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, + size_t tapfdSize, + virNetDevVPortProfilePtr virtPortProfile, + virNetDevVlanPtr virtVlan, ++ virNetDevCoalescePtr coalesce, + unsigned int mtu, + unsigned int *actualMTU, + unsigned int flags) +@@ -661,6 +663,9 @@ int virNetDevTapCreateInBridgePort(const char *brname, + if (virNetDevSetOnline(*ifname, !!(flags & VIR_NETDEV_TAP_CREATE_IFUP)) < 0) + goto error; + ++ if (virNetDevSetCoalesce(*ifname, coalesce) < 0) ++ goto error; ++ + return 0; + + error: +diff --git a/src/util/virnetdevtap.h b/src/util/virnetdevtap.h +index 6bb3b8891..bd5ec14d4 100644 +--- a/src/util/virnetdevtap.h ++++ b/src/util/virnetdevtap.h +@@ -24,6 +24,7 @@ + # define __VIR_NETDEV_TAP_H__ + + # include "internal.h" ++# include "virnetdev.h" + # include "virnetdevvportprofile.h" + # include "virnetdevvlan.h" + +@@ -83,6 +84,7 @@ int virNetDevTapCreateInBridgePort(const char *brname, + size_t tapfdSize, + virNetDevVPortProfilePtr virtPortProfile, + virNetDevVlanPtr virtVlan, ++ virNetDevCoalescePtr coalesce, + unsigned int mtu, + unsigned int *actualMTU, + unsigned int flags) +diff --git a/tests/bhyvexml2argvmock.c b/tests/bhyvexml2argvmock.c +index fd714694f..7afa0e34c 100644 +--- a/tests/bhyvexml2argvmock.c ++++ b/tests/bhyvexml2argvmock.c +@@ -28,6 +28,7 @@ int virNetDevTapCreateInBridgePort(const char *brname ATTRIBUTE_UNUSED, + size_t tapfdSize ATTRIBUTE_UNUSED, + virNetDevVPortProfilePtr virtPortProfile ATTRIBUTE_UNUSED, + virNetDevVlanPtr virtVlan ATTRIBUTE_UNUSED, ++ virNetDevCoalescePtr coalesce ATTRIBUTE_UNUSED, + unsigned int mtu ATTRIBUTE_UNUSED, + unsigned int *actualMTU ATTRIBUTE_UNUSED, + unsigned int fakeflags ATTRIBUTE_UNUSED) +-- +2.12.2 + diff --git a/SOURCES/libvirt-Split-out-virDomainIOMMUDefFormat.patch b/SOURCES/libvirt-Split-out-virDomainIOMMUDefFormat.patch new file mode 100644 index 0000000..5df4c85 --- /dev/null +++ b/SOURCES/libvirt-Split-out-virDomainIOMMUDefFormat.patch @@ -0,0 +1,56 @@ +From 0823b17d4ddc02a0bfca9fece7ff5ae3fd106a91 Mon Sep 17 00:00:00 2001 +Message-Id: <0823b17d4ddc02a0bfca9fece7ff5ae3fd106a91@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 16 May 2017 10:44:49 +0200 +Subject: [PATCH] Split out virDomainIOMMUDefFormat +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Make adding subelements easier. + +(cherry picked from commit d34ac94351255721ae86eba561cd2ba1d620ab7b) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1427005 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index a918ecd59..4096b9caf 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -24068,6 +24068,15 @@ virDomainDefIothreadShouldFormat(virDomainDefPtr def) + } + + ++static void ++virDomainIOMMUDefFormat(virBufferPtr buf, ++ const virDomainIOMMUDef *iommu) ++{ ++ virBufferAsprintf(buf, "\n", ++ virDomainIOMMUModelTypeToString(iommu->model)); ++} ++ ++ + /* This internal version appends to an existing buffer + * (possibly with auto-indent), rather than flattening + * to string. +@@ -24814,10 +24823,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, + goto error; + } + +- if (def->iommu) { +- virBufferAsprintf(buf, "\n", +- virDomainIOMMUModelTypeToString(def->iommu->model)); +- } ++ if (def->iommu) ++ virDomainIOMMUDefFormat(buf, def->iommu); + + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); +-- +2.13.0 + diff --git a/SOURCES/libvirt-Store-USB-port-path-as-an-array-of-integers.patch b/SOURCES/libvirt-Store-USB-port-path-as-an-array-of-integers.patch deleted file mode 100644 index c640541..0000000 --- a/SOURCES/libvirt-Store-USB-port-path-as-an-array-of-integers.patch +++ /dev/null @@ -1,200 +0,0 @@ -From 2debcb6bcdca2837ff5b44480d9f6addeaba76bc Mon Sep 17 00:00:00 2001 -Message-Id: <2debcb6bcdca2837ff5b44480d9f6addeaba76bc@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Thu, 21 Jul 2016 15:57:49 +0200 -Subject: [PATCH] Store USB port path as an array of integers -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -In preparation to tracking which USB addresses are occupied. -Introduce two helper functions for printing the port path -as a string and appending it to a virBuffer. - -(cherry picked from commit f820d5bf6fafa2932ee6b21c34fee4c464500ef3) -Signed-off-by: Ján Tomko - -https://bugzilla.redhat.com/show_bug.cgi?id=1215968 ---- - src/conf/device_conf.h | 2 +- - src/conf/domain_addr.c | 33 +++++++++++++++++++++++++++++++++ - src/conf/domain_addr.h | 12 ++++++++++++ - src/conf/domain_conf.c | 20 ++++++++++---------- - src/libvirt_private.syms | 3 +++ - src/qemu/qemu_command.c | 5 ++++- - 6 files changed, 63 insertions(+), 12 deletions(-) - -diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h -index 9b79160..8443de6 100644 ---- a/src/conf/device_conf.h -+++ b/src/conf/device_conf.h -@@ -84,7 +84,7 @@ typedef struct _virDomainDeviceCcidAddress { - - typedef struct _virDomainDeviceUSBAddress { - unsigned int bus; -- char *port; -+ unsigned int port[VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH]; - } virDomainDeviceUSBAddress, *virDomainDeviceUSBAddressPtr; - - typedef struct _virDomainDeviceSpaprVioAddress { -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 794270d..741d045 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1251,3 +1251,36 @@ virDomainVirtioSerialAddrRelease(virDomainVirtioSerialAddrSetPtr addrs, - VIR_FREE(str); - return ret; - } -+ -+ -+bool -+virDomainUSBAddressPortIsValid(unsigned int *port) -+{ -+ return port[0] != 0; -+} -+ -+ -+void -+virDomainUSBAddressPortFormatBuf(virBufferPtr buf, -+ unsigned int *port) -+{ -+ size_t i; -+ -+ for (i = 0; i < VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH; i++) { -+ if (port[i] == 0) -+ break; -+ virBufferAsprintf(buf, "%u.", port[i]); -+ } -+ virBufferTrim(buf, ".", -1); -+} -+ -+ -+char * -+virDomainUSBAddressPortFormat(unsigned int *port) -+{ -+ virBuffer buf = VIR_BUFFER_INITIALIZER; -+ virDomainUSBAddressPortFormatBuf(&buf, port); -+ if (virBufferCheckError(&buf) < 0) -+ return NULL; -+ return virBufferContentAndReset(&buf); -+} -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index f3eda89..cfc74d5 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -237,4 +237,16 @@ virDomainVirtioSerialAddrRelease(virDomainVirtioSerialAddrSetPtr addrs, - virDomainDeviceInfoPtr info) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - -+bool -+virDomainUSBAddressPortIsValid(unsigned int *port) -+ ATTRIBUTE_NONNULL(1); -+ -+void -+virDomainUSBAddressPortFormatBuf(virBufferPtr buf, -+ unsigned int *port) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); -+char * -+virDomainUSBAddressPortFormat(unsigned int *port) -+ ATTRIBUTE_NONNULL(1); -+ - #endif /* __DOMAIN_ADDR_H__ */ -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 0bd8a30..bc01633 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -32,6 +32,7 @@ - #include "internal.h" - #include "virerror.h" - #include "datatypes.h" -+#include "domain_addr.h" - #include "domain_conf.h" - #include "snapshot_conf.h" - #include "viralloc.h" -@@ -3313,8 +3314,6 @@ virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, - void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) - { - VIR_FREE(info->alias); -- if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) -- VIR_FREE(info->addr.usb.port); - memset(&info->addr, 0, sizeof(info->addr)); - info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; - VIR_FREE(info->romfile); -@@ -4860,7 +4859,11 @@ virDomainDeviceInfoFormat(virBufferPtr buf, - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB: - virBufferAsprintf(buf, " bus='%d'", info->addr.usb.bus); -- virBufferEscapeString(buf, " port='%s'", info->addr.usb.port); -+ if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) { -+ virBufferAddLit(buf, " port='"); -+ virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port); -+ virBufferAddLit(buf, "'"); -+ } - break; - - case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO: -@@ -5092,14 +5095,14 @@ virDomainDeviceCcidAddressParseXML(xmlNodePtr node, - } - - static int --virDomainDeviceUSBAddressParsePort(char *port) -+virDomainDeviceUSBAddressParsePort(virDomainDeviceUSBAddressPtr addr, -+ char *port) - { -- unsigned int p; - char *tmp = port; - size_t i; - - for (i = 0; i < VIR_DOMAIN_DEVICE_USB_MAX_PORT_DEPTH; i++) { -- if (virStrToLong_uip(tmp, &tmp, 10, &p) < 0) -+ if (virStrToLong_uip(tmp, &tmp, 10, &addr->port[i]) < 0) - break; - - if (*tmp == '\0') -@@ -5126,12 +5129,9 @@ virDomainDeviceUSBAddressParseXML(xmlNodePtr node, - port = virXMLPropString(node, "port"); - bus = virXMLPropString(node, "bus"); - -- if (port && virDomainDeviceUSBAddressParsePort(port) < 0) -+ if (port && virDomainDeviceUSBAddressParsePort(addr, port) < 0) - goto cleanup; - -- addr->port = port; -- port = NULL; -- - if (bus && - virStrToLong_uip(bus, NULL, 10, &addr->bus) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index de620a8..44b78e0 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -107,6 +107,9 @@ virDomainPCIAddressSetGrow; - virDomainPCIAddressSlotInUse; - virDomainPCIAddressValidate; - virDomainPCIControllerModelToConnectType; -+virDomainUSBAddressPortFormat; -+virDomainUSBAddressPortFormatBuf; -+virDomainUSBAddressPortIsValid; - virDomainVirtioSerialAddrAssign; - virDomainVirtioSerialAddrAutoAssign; - virDomainVirtioSerialAddrIsComplete; -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index af6146f..300c01c 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -376,7 +376,10 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, - info->addr.usb.bus))) - goto cleanup; - virBufferAsprintf(buf, ",bus=%s.0", contAlias); -- virBufferEscapeString(buf, ",port=%s", info->addr.usb.port); -+ if (virDomainUSBAddressPortIsValid(info->addr.usb.port)) { -+ virBufferAddLit(buf, ",port="); -+ virDomainUSBAddressPortFormatBuf(buf, info->addr.usb.port); -+ } - } else if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO) { - if (info->addr.spaprvio.has_reg) - virBufferAsprintf(buf, ",reg=0x%llx", info->addr.spaprvio.reg); --- -2.9.2 - diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-controller-driver.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-controller-driver.patch new file mode 100644 index 0000000..8c44da7 --- /dev/null +++ b/SOURCES/libvirt-Use-a-separate-buffer-for-controller-driver.patch @@ -0,0 +1,81 @@ +From 4e32b3e8ab394aaf1f94b1166d7c5e38cec8ede4 Mon Sep 17 00:00:00 2001 +Message-Id: <4e32b3e8ab394aaf1f94b1166d7c5e38cec8ede4@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:48:53 +0200 +Subject: [PATCH] Use a separate buffer for +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Make adding new attributes easier. + +(cherry picked from commit 5e5fc766257b05979c37593434d28cc9eb7e0cf0) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 39 ++++++++++++++++++++------------------- + 1 file changed, 20 insertions(+), 19 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index d5c5a7030b..242a79a7e7 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -21332,6 +21332,7 @@ virDomainControllerDefFormat(virBufferPtr buf, + const char *model = NULL; + const char *modelName = NULL; + bool pcihole64 = false, pciModel = false, pciTarget = false; ++ virBuffer driverBuf = VIR_BUFFER_INITIALIZER; + + if (!type) { + virReportError(VIR_ERR_INTERNAL_ERROR, +@@ -21436,26 +21437,26 @@ virDomainControllerDefFormat(virBufferPtr buf, + } + } + +- if (def->queues || def->cmd_per_lun || +- def->max_sectors || def->ioeventfd || def->iothread) { ++ if (def->queues) ++ virBufferAsprintf(&driverBuf, " queues='%u'", def->queues); ++ ++ if (def->cmd_per_lun) ++ virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun); ++ ++ if (def->max_sectors) ++ virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors); ++ ++ if (def->ioeventfd) { ++ virBufferAsprintf(&driverBuf, " ioeventfd='%s'", ++ virTristateSwitchTypeToString(def->ioeventfd)); ++ } ++ ++ if (def->iothread) ++ virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread); ++ ++ if (virBufferUse(&driverBuf)) { + virBufferAddLit(buf, "queues) +- virBufferAsprintf(buf, " queues='%u'", def->queues); +- +- if (def->cmd_per_lun) +- virBufferAsprintf(buf, " cmd_per_lun='%u'", def->cmd_per_lun); +- +- if (def->max_sectors) +- virBufferAsprintf(buf, " max_sectors='%u'", def->max_sectors); +- +- if (def->ioeventfd) { +- virBufferAsprintf(buf, " ioeventfd='%s'", +- virTristateSwitchTypeToString(def->ioeventfd)); +- } +- +- if (def->iothread) +- virBufferAsprintf(buf, " iothread='%u'", def->iothread); +- ++ virBufferAddBuffer(buf, &driverBuf); + virBufferAddLit(buf, "/>\n"); + } + +-- +2.13.1 + diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-disk-driver.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-disk-driver.patch new file mode 100644 index 0000000..d623c15 --- /dev/null +++ b/SOURCES/libvirt-Use-a-separate-buffer-for-disk-driver.patch @@ -0,0 +1,99 @@ +From 0f6008b1fa9b236f673163a123b71aeebb6b4454 Mon Sep 17 00:00:00 2001 +Message-Id: <0f6008b1fa9b236f673163a123b71aeebb6b4454@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:48:52 +0200 +Subject: [PATCH] Use a separate buffer for +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Eliminate the big condition at the start. +Instead use a buffer and only format the element if the buffer +is non-empty. + +(cherry picked from commit d89803d27c3088aff6f4d062a578fc9938a80e04) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 55 +++++++++++++++++++++++++------------------------- + 1 file changed, 27 insertions(+), 28 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 4228cad610..d5c5a7030b 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -21088,6 +21088,7 @@ virDomainDiskDefFormat(virBufferPtr buf, + const char *sgio = virDomainDeviceSGIOTypeToString(def->sgio); + const char *discard = virDomainDiskDiscardTypeToString(def->discard); + const char *detect_zeroes = virDomainDiskDetectZeroesTypeToString(def->detect_zeroes); ++ virBuffer driverBuf = VIR_BUFFER_INITIALIZER; + + if (!type || !def->src->type) { + virReportError(VIR_ERR_INTERNAL_ERROR, +@@ -21139,35 +21140,33 @@ virDomainDiskDefFormat(virBufferPtr buf, + virBufferAddLit(buf, ">\n"); + virBufferAdjustIndent(buf, 2); + +- if (def->src->driverName || def->src->format > 0 || def->cachemode || +- def->error_policy || def->rerror_policy || def->iomode || +- def->ioeventfd || def->event_idx || def->copy_on_read || +- def->discard || def->iothread || def->detect_zeroes) { ++ virBufferEscapeString(&driverBuf, " name='%s'", def->src->driverName); ++ if (def->src->format > 0) ++ virBufferAsprintf(&driverBuf, " type='%s'", ++ virStorageFileFormatTypeToString(def->src->format)); ++ if (def->cachemode) ++ virBufferAsprintf(&driverBuf, " cache='%s'", cachemode); ++ if (def->error_policy) ++ virBufferAsprintf(&driverBuf, " error_policy='%s'", error_policy); ++ if (def->rerror_policy) ++ virBufferAsprintf(&driverBuf, " rerror_policy='%s'", rerror_policy); ++ if (def->iomode) ++ virBufferAsprintf(&driverBuf, " io='%s'", iomode); ++ if (def->ioeventfd) ++ virBufferAsprintf(&driverBuf, " ioeventfd='%s'", ioeventfd); ++ if (def->event_idx) ++ virBufferAsprintf(&driverBuf, " event_idx='%s'", event_idx); ++ if (def->copy_on_read) ++ virBufferAsprintf(&driverBuf, " copy_on_read='%s'", copy_on_read); ++ if (def->discard) ++ virBufferAsprintf(&driverBuf, " discard='%s'", discard); ++ if (def->iothread) ++ virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread); ++ if (def->detect_zeroes) ++ virBufferAsprintf(&driverBuf, " detect_zeroes='%s'", detect_zeroes); ++ if (virBufferUse(&driverBuf)) { + virBufferAddLit(buf, "src->driverName); +- if (def->src->format > 0) +- virBufferAsprintf(buf, " type='%s'", +- virStorageFileFormatTypeToString(def->src->format)); +- if (def->cachemode) +- virBufferAsprintf(buf, " cache='%s'", cachemode); +- if (def->error_policy) +- virBufferAsprintf(buf, " error_policy='%s'", error_policy); +- if (def->rerror_policy) +- virBufferAsprintf(buf, " rerror_policy='%s'", rerror_policy); +- if (def->iomode) +- virBufferAsprintf(buf, " io='%s'", iomode); +- if (def->ioeventfd) +- virBufferAsprintf(buf, " ioeventfd='%s'", ioeventfd); +- if (def->event_idx) +- virBufferAsprintf(buf, " event_idx='%s'", event_idx); +- if (def->copy_on_read) +- virBufferAsprintf(buf, " copy_on_read='%s'", copy_on_read); +- if (def->discard) +- virBufferAsprintf(buf, " discard='%s'", discard); +- if (def->iothread) +- virBufferAsprintf(buf, " iothread='%u'", def->iothread); +- if (def->detect_zeroes) +- virBufferAsprintf(buf, " detect_zeroes='%s'", detect_zeroes); ++ virBufferAddBuffer(buf, &driverBuf); + virBufferAddLit(buf, "/>\n"); + } + +-- +2.13.1 + diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-filesystem-driver.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-filesystem-driver.patch new file mode 100644 index 0000000..e1d6b72 --- /dev/null +++ b/SOURCES/libvirt-Use-a-separate-buffer-for-filesystem-driver.patch @@ -0,0 +1,61 @@ +From 71aa3b75eb2f6e01c0c8e0d1bc5c0d29e310d3fd Mon Sep 17 00:00:00 2001 +Message-Id: <71aa3b75eb2f6e01c0c8e0d1bc5c0d29e310d3fd@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:48:54 +0200 +Subject: [PATCH] Use a separate buffer for +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Format the attributes in a separate buffer and only +print the element if it's not empty. + +(cherry picked from commit 8d704e6cf7da60156a0b25b165d4780e99a0fa2f) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 242a79a7e7..e004559f9f 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -21504,6 +21504,7 @@ virDomainFSDefFormat(virBufferPtr buf, + const char *fsdriver = virDomainFSDriverTypeToString(def->fsdriver); + const char *wrpolicy = virDomainFSWrpolicyTypeToString(def->wrpolicy); + const char *src = def->src->path; ++ virBuffer driverBuf = VIR_BUFFER_INITIALIZER; + + if (!type) { + virReportError(VIR_ERR_INTERNAL_ERROR, +@@ -21523,16 +21524,21 @@ virDomainFSDefFormat(virBufferPtr buf, + type, accessmode); + virBufferAdjustIndent(buf, 2); + if (def->fsdriver) { +- virBufferAsprintf(buf, "format) +- virBufferAsprintf(buf, " format='%s'", ++ virBufferAsprintf(&driverBuf, " format='%s'", + virStorageFileFormatTypeToString(def->format)); + + /* Don't generate anything if wrpolicy is set to default */ + if (def->wrpolicy) +- virBufferAsprintf(buf, " wrpolicy='%s'", wrpolicy); ++ virBufferAsprintf(&driverBuf, " wrpolicy='%s'", wrpolicy); + ++ } ++ ++ if (virBufferUse(&driverBuf)) { ++ virBufferAddLit(buf, "\n"); + } + +-- +2.13.1 + diff --git a/SOURCES/libvirt-Use-a-separate-buffer-for-input-subelements.patch b/SOURCES/libvirt-Use-a-separate-buffer-for-input-subelements.patch new file mode 100644 index 0000000..89dd9e0 --- /dev/null +++ b/SOURCES/libvirt-Use-a-separate-buffer-for-input-subelements.patch @@ -0,0 +1,65 @@ +From c8fc71708382f37cfc7437b15f58e3d5ab1f2cb1 Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:48:51 +0200 +Subject: [PATCH] Use a separate buffer for subelements +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Instead of figuring out upfront whether will be a single +or a pair element, format the subelements into a separate buffer +and close early if this buffer is empty. + +(cherry picked from commit 51219e11b8c57c7a9755eedd72986269b78ccfb7) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 21 +++++++++++---------- + 1 file changed, 11 insertions(+), 10 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index b473ce6b1e..4228cad610 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -23152,6 +23152,7 @@ virDomainInputDefFormat(virBufferPtr buf, + { + const char *type = virDomainInputTypeToString(def->type); + const char *bus = virDomainInputBusTypeToString(def->bus); ++ virBuffer childbuf = VIR_BUFFER_INITIALIZER; + + /* don't format keyboard into migratable XML for backward compatibility */ + if (flags & VIR_DOMAIN_DEF_FORMAT_MIGRATABLE && +@@ -23174,17 +23175,17 @@ virDomainInputDefFormat(virBufferPtr buf, + virBufferAsprintf(buf, "info, flags) || +- def->type == VIR_DOMAIN_INPUT_TYPE_PASSTHROUGH) { +- virBufferAddLit(buf, ">\n"); +- virBufferAdjustIndent(buf, 2); +- virBufferEscapeString(buf, "\n", def->source.evdev); +- if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) +- return -1; +- virBufferAdjustIndent(buf, -2); +- virBufferAddLit(buf, "\n"); +- } else { ++ virBufferAdjustIndent(&childbuf, virBufferGetIndent(buf, false) + 2); ++ virBufferEscapeString(&childbuf, "\n", def->source.evdev); ++ if (virDomainDeviceInfoFormat(&childbuf, &def->info, flags) < 0) ++ return -1; ++ ++ if (!virBufferUse(&childbuf)) { + virBufferAddLit(buf, "/>\n"); ++ } else { ++ virBufferAddLit(buf, ">\n"); ++ virBufferAddBuffer(buf, &childbuf); ++ virBufferAddLit(buf, "\n"); + } + + return 0; +-- +2.13.1 + diff --git a/SOURCES/libvirt-add-virtio-related-options-to-memballoon.patch b/SOURCES/libvirt-add-virtio-related-options-to-memballoon.patch new file mode 100644 index 0000000..8204d2b --- /dev/null +++ b/SOURCES/libvirt-add-virtio-related-options-to-memballoon.patch @@ -0,0 +1,147 @@ +From f9a338cd5d0477291a0001a527d0add941f7ea37 Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:49:01 +0200 +Subject: [PATCH] add virtio-related options to memballoon +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 + +Reviewed-by: Pavel Hrdina +(cherry picked from commit 82223f9364a9f47a39b7c66c241b82ae62f9fb4b) +Signed-off-by: Ján Tomko +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 7 +++++++ + docs/schemas/domaincommon.rng | 5 +++++ + src/conf/domain_conf.c | 24 ++++++++++++++++++++++ + src/conf/domain_conf.h | 1 + + .../qemuxml2argv-virtio-options.xml | 1 + + 5 files changed, 38 insertions(+) + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index 23546daae9..2556f383fc 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -6913,6 +6913,7 @@ qemu-kvm -net nic,model=? /dev/null + <memballoon model='virtio'> + <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> + <stats period='10'/> ++ <driver iommu='on' ats='on'/> + </memballoon> + </devices> + </domain> +@@ -6957,6 +6958,12 @@ qemu-kvm -net nic,model=? /dev/null + Since 1.1.1, requires QEMU 1.5 +

+
++
driver
++
++ For model virtio memballoon, ++ Virtio-specific options can also be ++ set. (Since 3.5.0) ++
+ +

Random number generator device

+ +diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng +index 9e68bbc52d..f571af6706 100644 +--- a/docs/schemas/domaincommon.rng ++++ b/docs/schemas/domaincommon.rng +@@ -3730,6 +3730,11 @@ + + + ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index bba50cf3fd..4768d02029 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -2292,6 +2292,7 @@ void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def) + return; + + virDomainDeviceInfoClear(&def->info); ++ VIR_FREE(def->virtio); + + VIR_FREE(def); + } +@@ -12970,6 +12971,9 @@ virDomainMemballoonDefParseXML(xmlNodePtr node, + else if (virDomainDeviceInfoParseXML(node, NULL, &def->info, flags) < 0) + goto error; + ++ if (virDomainVirtioOptionsParseXML(ctxt, &def->virtio) < 0) ++ goto error; ++ + cleanup: + VIR_FREE(model); + VIR_FREE(deflate); +@@ -19582,6 +19586,10 @@ virDomainMemballoonDefCheckABIStability(virDomainMemballoonDefPtr src, + return false; + } + ++ if (src->virtio && dst->virtio && ++ !virDomainVirtioOptionsCheckABIStability(src->virtio, dst->virtio)) ++ return false; ++ + if (!virDomainDeviceInfoCheckABIStability(&src->info, &dst->info)) + return false; + +@@ -22934,6 +22942,22 @@ virDomainMemballoonDefFormat(virBufferPtr buf, + return -1; + } + ++ if (def->virtio) { ++ virBuffer driverBuf = VIR_BUFFER_INITIALIZER; ++ ++ virDomainVirtioOptionsFormat(&driverBuf, def->virtio); ++ ++ if (virBufferCheckError(&driverBuf) < 0) { ++ virBufferFreeAndReset(&childrenBuf); ++ return -1; ++ } ++ if (virBufferUse(&driverBuf)) { ++ virBufferAddLit(&childrenBuf, "\n"); ++ } ++ } ++ + if (!virBufferUse(&childrenBuf)) { + virBufferAddLit(buf, "/>\n"); + } else { +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 603d35bd50..f1f9208b91 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -1609,6 +1609,7 @@ struct _virDomainMemballoonDef { + virDomainDeviceInfo info; + int period; /* seconds between collections */ + int autodeflate; /* enum virTristateSwitch */ ++ virDomainVirtioOptionsPtr virtio; + }; + + struct _virDomainNVRAMDef { +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml +index 3357bc6d1b..b16a9847fe 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml ++++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-options.xml +@@ -73,6 +73,7 @@ + + +
++ + + + /dev/random +-- +2.13.1 + diff --git a/SOURCES/libvirt-admin-Fix-default-uri-config-option-name-s-admin_uri_default-uri_default.patch b/SOURCES/libvirt-admin-Fix-default-uri-config-option-name-s-admin_uri_default-uri_default.patch deleted file mode 100644 index b296720..0000000 --- a/SOURCES/libvirt-admin-Fix-default-uri-config-option-name-s-admin_uri_default-uri_default.patch +++ /dev/null @@ -1,79 +0,0 @@ -From a13eac3b9909d824e1f821b869ae166a25479121 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Erik Skultety -Date: Tue, 16 Aug 2016 13:06:03 +0200 -Subject: [PATCH] admin: Fix default uri config option name - s/admin_uri_default/uri_default - -The original name 'admin_uri_default' was introduced to our code by commit -dbecb87f. However, at that time we already had a separate config file for -admin library but the commit mentioned above didn't properly adjust the -config's option name. The result is that when we're loading the config, we -check a non-existent config option (there's not much to do with the URIs -anyway, since we only allow local connection). Additionally, virt-admin's man -page documents, that the default URI can be altered by setting -admin_uri_default option. So the fix proposed by this patch leaves the -libvirt-admin.conf as is and adjusts the naming in the code as well as in the -virt-admin's man page. - -Signed-off-by: Erik Skultety -(cherry picked from commit f5f32bcd1bb7d96b38c34a85658ac0996683f8bc) - -https://bugzilla.redhat.com/show_bug.cgi?id=1367269 -Signed-off-by: Erik Skultety - - Conflicts: - src/libvirt-admin.c - conflicts caused by downstream commit 00f1be9c - which had to be modified compared to its upstream original f5da0d18 - that was relying on some newly added accessors which were not - backported. ---- - src/libvirt-admin.c | 4 ++-- - tools/virt-admin.pod | 7 ++++--- - 2 files changed, 6 insertions(+), 5 deletions(-) - -diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c -index c485752..f3bbe8c 100644 ---- a/src/libvirt-admin.c -+++ b/src/libvirt-admin.c -@@ -169,10 +169,10 @@ virAdmGetDefaultURI(virConfPtr conf, char **uristr) - return -1; - VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", *uristr); - } else { -- if ((value = virConfGetValue(conf, "admin_uri_default"))) { -+ if ((value = virConfGetValue(conf, "uri_default"))) { - if (value->type != VIR_CONF_STRING) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", -- _("Expected a string for 'admin_uri_default' " -+ _("Expected a string for 'uri_default' " - "config parameter")); - return -1; - } -diff --git a/tools/virt-admin.pod b/tools/virt-admin.pod -index afc4689..49b267f 100644 ---- a/tools/virt-admin.pod -+++ b/tools/virt-admin.pod -@@ -127,7 +127,7 @@ Will print the current directory. - - (Re)-Connect to a daemon's administrating server. The I parameter - specifies how to connect to the administrating server. --If I or I (see below) were set, -+If I or I (see below) were set, - I is automatically issued every time a command that requires an - active connection is executed. Note that this only applies if there is no - connection at all or there is an inactive one. -@@ -140,8 +140,9 @@ L on how to make URIs. - =item B - - Prints the administrating server canonical URI, can be useful in shell mode. If --no I was specified, neither I or --I were set, libvirtd:///system is used. -+no I was specified, neither I environment -+variable nor I option (libvirt-admin.conf) were set, -+libvirtd:///system is used. - - =back - --- -2.9.2 - diff --git a/SOURCES/libvirt-admin-Fix-the-default-uri-for-session-daemon-to-libvirtd-session.patch b/SOURCES/libvirt-admin-Fix-the-default-uri-for-session-daemon-to-libvirtd-session.patch deleted file mode 100644 index c2cc01f..0000000 --- a/SOURCES/libvirt-admin-Fix-the-default-uri-for-session-daemon-to-libvirtd-session.patch +++ /dev/null @@ -1,47 +0,0 @@ -From eb41dae660606b398ee7366829f9f5a41c686887 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Erik Skultety -Date: Tue, 9 Aug 2016 16:09:21 +0200 -Subject: [PATCH] admin: Fix the default uri for session daemon to - libvirtd:///session - -Just like we decide on which URI we go with based on EUID for qemu in remote -driver, do a similar thing for admin except we do not spawn a daemon in this -case. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1356858 - -Signed-off-by: Erik Skultety -(cherry picked from commit 30ce2f0e2ad1335df6e4c9053eae822963531f97) -Signed-off-by: Erik Skultety - - Conflicts: - src/libvirt-admin.c - conflict caused by commit f5da0d18 which changed - the returned type of virAdmGetDefaultURI but was not backported ---- - src/libvirt-admin.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c -index f07cb10..fb2f7b8 100644 ---- a/src/libvirt-admin.c -+++ b/src/libvirt-admin.c -@@ -181,9 +181,13 @@ virAdmGetDefaultURI(virConfPtr conf) - /* Since we can't probe connecting via any hypervisor driver as libvirt - * does, if no explicit URI was given and neither the environment - * variable, nor the configuration parameter had previously been set, -- * we set the default admin server URI to 'libvirtd://system'. -+ * we set the default admin server URI to 'libvirtd:///system' or -+ * 'libvirtd:///session' depending on the process's EUID. - */ -- uristr = "libvirtd:///system"; -+ if (geteuid() == 0) -+ uristr = "libvirtd:///system"; -+ else -+ uristr = "libvirtd:///session"; - } - - return uristr; --- -2.9.2 - diff --git a/SOURCES/libvirt-admin-Retrieve-the-SASL-context-for-both-local-and-remote-connection.patch b/SOURCES/libvirt-admin-Retrieve-the-SASL-context-for-both-local-and-remote-connection.patch deleted file mode 100644 index 6973efb..0000000 --- a/SOURCES/libvirt-admin-Retrieve-the-SASL-context-for-both-local-and-remote-connection.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 342133607ff39eac851667f4a86abd9b97f3cf22 Mon Sep 17 00:00:00 2001 -Message-Id: <342133607ff39eac851667f4a86abd9b97f3cf22@dist-git> -From: Erik Skultety -Date: Tue, 2 Aug 2016 08:47:44 +0200 -Subject: [PATCH] admin: Retrieve the SASL context for both local and remote - connection - -When commit 4a0e9108 added a support for client information retrieval, it made -the API return SASL identity info only for clients connected remotely, yet SASL -can be happily used with UNIX sockets as well. - -Signed-off-by: Erik Skultety -(cherry picked from commit 385ec6280fdad8548b5997577b91931d1ed79aaa) - -https://bugzilla.redhat.com/show_bug.cgi?id=1361948 -Signed-off-by: Erik Skultety ---- - daemon/admin_server.c | 14 +++++++------- - 1 file changed, 7 insertions(+), 7 deletions(-) - -diff --git a/daemon/admin_server.c b/daemon/admin_server.c -index 9f24f68..5bbf229 100644 ---- a/daemon/admin_server.c -+++ b/daemon/admin_server.c -@@ -237,19 +237,19 @@ adminClientGetInfo(virNetServerClientPtr client, - readonly) < 0) - goto cleanup; - -+ if (virIdentityGetSASLUserName(identity, &attr) < 0 || -+ (attr && -+ virTypedParamsAddString(&tmpparams, nparams, &maxparams, -+ VIR_CLIENT_INFO_SASL_USER_NAME, -+ attr) < 0)) -+ goto cleanup; -+ - if (!virNetServerClientIsLocal(client)) { - if (virTypedParamsAddString(&tmpparams, nparams, &maxparams, - VIR_CLIENT_INFO_SOCKET_ADDR, - sock_addr) < 0) - goto cleanup; - -- if (virIdentityGetSASLUserName(identity, &attr) < 0 || -- (attr && -- virTypedParamsAddString(&tmpparams, nparams, &maxparams, -- VIR_CLIENT_INFO_SASL_USER_NAME, -- attr) < 0)) -- goto cleanup; -- - if (virIdentityGetX509DName(identity, &attr) < 0 || - (attr && - virTypedParamsAddString(&tmpparams, nparams, &maxparams, --- -2.9.2 - diff --git a/SOURCES/libvirt-admin-rpc-virnetserver-Fix-updating-of-the-client-limits.patch b/SOURCES/libvirt-admin-rpc-virnetserver-Fix-updating-of-the-client-limits.patch deleted file mode 100644 index 89a6c56..0000000 --- a/SOURCES/libvirt-admin-rpc-virnetserver-Fix-updating-of-the-client-limits.patch +++ /dev/null @@ -1,40 +0,0 @@ -From e9c3dd530daa481e2c3e5b63bf19c0360ee225c2 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Erik Skultety -Date: Tue, 2 Aug 2016 15:20:53 +0200 -Subject: [PATCH] admin: rpc: virnetserver: Fix updating of the client limits - -Commit 2737aaaf changed our policy for accepting new clients in a way, that -instead of accepting new clients only to disconnect them immediately, since -that would overcommit the limit, we temporarily disable polling for the -dedicated file descriptor, so any new connection will queue on the socket. -Commit 8b1f0469 then added the possibility to change the limits during runtime -but it didn't re-enable polling for the previously disabled file descriptor, -thus any new connection would still continue to queue on the socket. This patch -forces an update of the services each time the limits were changed in some way. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1357776 - -Signed-off-by: Erik Skultety -(cherry picked from commit e9ce8a7d24a94f0be19705ae0e63aaa054c39e88) -Signed-off-by: Erik Skultety ---- - src/rpc/virnetserver.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c -index c5caef3..5b6bc4a 100644 ---- a/src/rpc/virnetserver.c -+++ b/src/rpc/virnetserver.c -@@ -1071,6 +1071,8 @@ virNetServerSetClientLimits(virNetServerPtr srv, - if (maxClientsUnauth >= 0) - srv->nclients_unauth_max = maxClientsUnauth; - -+ virNetServerCheckLimits(srv); -+ - ret = 0; - cleanup: - virObjectUnlock(srv); --- -2.9.2 - diff --git a/SOURCES/libvirt-audit-Audit-information-about-shmem-devices.patch b/SOURCES/libvirt-audit-Audit-information-about-shmem-devices.patch deleted file mode 100644 index 8a7d2c3..0000000 --- a/SOURCES/libvirt-audit-Audit-information-about-shmem-devices.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 806108ea6df82f0702a5933feb75691828f9cabe Mon Sep 17 00:00:00 2001 -Message-Id: <806108ea6df82f0702a5933feb75691828f9cabe@dist-git> -From: Martin Kletzander -Date: Wed, 14 Sep 2016 12:49:18 +0200 -Subject: [PATCH] audit: Audit information about shmem devices - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603 - -Signed-off-by: Martin Kletzander -(cherry picked from commit 94e2be842411b9f8ec9165c8d25c93716c1b30ca) -Signed-off-by: Martin Kletzander ---- - docs/auditlog.html.in | 19 +++++++++++++++++++ - src/conf/domain_audit.c | 42 ++++++++++++++++++++++++++++++++++++++++++ - src/conf/domain_audit.h | 4 ++++ - src/libvirt_private.syms | 1 + - 4 files changed, 66 insertions(+) - -diff --git a/docs/auditlog.html.in b/docs/auditlog.html.in -index 012d068..0c778aa 100644 ---- a/docs/auditlog.html.in -+++ b/docs/auditlog.html.in -@@ -352,5 +352,24 @@ -
The name of the cgroup controller
- - -+ -+

Shared memory

-+

-+ The msg field will include the following sub-fields -+

-+ -+
-+
resrc
-+
The type of resource assigned. Set to shmem
-+
reason
-+
The reason which caused the resource to be assigned to happen
-+
size
-+
The size of the shared memory region
-+
shmem
-+
Name of the shared memory region
-+
source
-+
Path of the backing character device for given emulated device
-+
-+ - - -diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c -index 6ad0acb..f0cc49c 100644 ---- a/src/conf/domain_audit.c -+++ b/src/conf/domain_audit.c -@@ -889,6 +889,9 @@ virDomainAuditStart(virDomainObjPtr vm, const char *reason, bool success) - if (vm->def->tpm) - virDomainAuditTPM(vm, vm->def->tpm, "start", true); - -+ for (i = 0; i < vm->def->nshmems; i++) -+ virDomainAuditShmem(vm, vm->def->shmems[i], "start", true); -+ - virDomainAuditMemory(vm, 0, virDomainDefGetMemoryTotal(vm->def), - "start", true); - virDomainAuditVcpu(vm, 0, virDomainDefGetVcpus(vm->def), "start", true); -@@ -963,3 +966,42 @@ virDomainAuditSecurityLabel(virDomainObjPtr vm, bool success) - - VIR_FREE(vmname); - } -+ -+void -+virDomainAuditShmem(virDomainObjPtr vm, -+ virDomainShmemDefPtr def, -+ const char *reason, bool success) -+{ -+ char uuidstr[VIR_UUID_STRING_BUFLEN]; -+ char *vmname = virAuditEncode("vm", vm->def->name); -+ const char *srcpath = virDomainAuditChardevPath(&def->server.chr); -+ char *src = virAuditEncode("server", VIR_AUDIT_STR(srcpath)); -+ char *shmem = virAuditEncode("shmem", VIR_AUDIT_STR(def->name)); -+ const char *virt = virDomainVirtTypeToString(vm->def->virtType); -+ char *size = NULL; -+ -+ virUUIDFormat(vm->def->uuid, uuidstr); -+ -+ if (!vmname || !src || !size || !shmem || -+ virAsprintfQuiet(&size, "%llu", def->size) < 0) { -+ VIR_WARN("OOM while encoding audit message"); -+ goto cleanup; -+ } -+ -+ if (!virt) { -+ VIR_WARN("Unexpected virt type %d while encoding audit message", -+ vm->def->virtType); -+ virt = "?"; -+ } -+ -+ VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success, -+ "virt=%s resrc=shmem reason=%s %s uuid=%s size=%s %s %s", -+ virt, reason, vmname, uuidstr, size ?: "?", shmem, src); -+ -+ cleanup: -+ VIR_FREE(vmname); -+ VIR_FREE(src); -+ VIR_FREE(size); -+ VIR_FREE(shmem); -+ return; -+} -diff --git a/src/conf/domain_audit.h b/src/conf/domain_audit.h -index 97dadca..8cb585d 100644 ---- a/src/conf/domain_audit.h -+++ b/src/conf/domain_audit.h -@@ -129,6 +129,10 @@ void virDomainAuditRNG(virDomainObjPtr vm, - const char *reason, - bool success) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4); -+void virDomainAuditShmem(virDomainObjPtr vm, -+ virDomainShmemDefPtr def, -+ const char *reason, bool success) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3); - - - #endif /* __VIR_DOMAIN_AUDIT_H__ */ -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 92475a2..5878360 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -145,6 +145,7 @@ virDomainAuditNetDevice; - virDomainAuditRedirdev; - virDomainAuditRNG; - virDomainAuditSecurityLabel; -+virDomainAuditShmem; - virDomainAuditStart; - virDomainAuditStop; - virDomainAuditVcpu; --- -2.10.0 - diff --git a/SOURCES/libvirt-audit-Fix-the-output-message-for-shmem.patch b/SOURCES/libvirt-audit-Fix-the-output-message-for-shmem.patch new file mode 100644 index 0000000..c3e819a --- /dev/null +++ b/SOURCES/libvirt-audit-Fix-the-output-message-for-shmem.patch @@ -0,0 +1,70 @@ +From c71f920357ffb17cd13aaf9a12e8d77d1b29b08c Mon Sep 17 00:00:00 2001 +Message-Id: +From: Martin Kletzander +Date: Mon, 5 Jun 2017 17:02:03 +0200 +Subject: [PATCH] audit: Fix the output message for shmem + +After some discussion on and off the linux-audit mailing list, we +should use different fields for the audit messages. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1218603 + +Signed-off-by: Martin Kletzander +(cherry picked from commit 6d12a1cb2fb0e0152a19518423dceafa7cf088fb) +Signed-off-by: Martin Kletzander +Signed-off-by: Jiri Denemark +--- + src/conf/domain_audit.c | 24 +++++++++++++----------- + 1 file changed, 13 insertions(+), 11 deletions(-) + +diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c +index 2d9ff5e3ff..1e667af73c 100644 +--- a/src/conf/domain_audit.c ++++ b/src/conf/domain_audit.c +@@ -983,15 +983,13 @@ virDomainAuditShmem(virDomainObjPtr vm, + char uuidstr[VIR_UUID_STRING_BUFLEN]; + char *vmname = virAuditEncode("vm", vm->def->name); + const char *srcpath = virDomainAuditChardevPath(&def->server.chr); +- char *src = virAuditEncode("server", VIR_AUDIT_STR(srcpath)); +- char *shmem = virAuditEncode("shmem", VIR_AUDIT_STR(def->name)); + const char *virt = virDomainVirtTypeToString(vm->def->virtType); +- char *size = NULL; ++ char *shmpath = NULL; + + virUUIDFormat(vm->def->uuid, uuidstr); + +- if (!vmname || !src || !shmem || +- virAsprintfQuiet(&size, "%llu", def->size) < 0) { ++ if (!vmname || ++ virAsprintfQuiet(&shmpath, "/dev/shm/%s", def->name) < 0) { + VIR_WARN("OOM while encoding audit message"); + goto cleanup; + } +@@ -1002,14 +1000,18 @@ virDomainAuditShmem(virDomainObjPtr vm, + virt = "?"; + } + +- VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success, +- "virt=%s resrc=shmem reason=%s %s uuid=%s size=%s %s %s", +- virt, reason, vmname, uuidstr, size, shmem, src); ++ if (def->server.enabled) { ++ VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success, ++ "virt=%s resrc=ivshmem-socket reason=%s %s uuid=%s path=%s", ++ virt, reason, vmname, uuidstr, VIR_AUDIT_STR(srcpath)); ++ } else { ++ VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success, ++ "virt=%s resrc=shmem reason=%s %s uuid=%s size=%llu path=%s", ++ virt, reason, vmname, uuidstr, def->size, VIR_AUDIT_STR(shmpath)); ++ } + + cleanup: + VIR_FREE(vmname); +- VIR_FREE(src); +- VIR_FREE(size); +- VIR_FREE(shmem); ++ VIR_FREE(shmpath); + return; + } +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-Add-IOThread-quota-and-period-scheduler-cputune-defs.patch b/SOURCES/libvirt-conf-Add-IOThread-quota-and-period-scheduler-cputune-defs.patch deleted file mode 100644 index 3c50720..0000000 --- a/SOURCES/libvirt-conf-Add-IOThread-quota-and-period-scheduler-cputune-defs.patch +++ /dev/null @@ -1,280 +0,0 @@ -From e40f868e4f974ea0bd7224f5d49e602cf2947570 Mon Sep 17 00:00:00 2001 -Message-Id: -From: John Ferlan -Date: Tue, 6 Sep 2016 16:43:13 -0400 -Subject: [PATCH] conf: Add IOThread quota and period scheduler/cputune defs - -https://bugzilla.redhat.com/show_bug.cgi?id=1356937 - -Add the definitions to allow for viewing/setting cgroup period and quota -limits for IOThreads. - -This is similar to the work done for emulator quota and period by -commit ids 'b65dafa' and 'e051c482'. - -Being able to view/set the IOThread specific values is related to more -recent changes adding global period (commmit id '4d92d58f') and global -quota (commit id '55ecdae') definitions and qemu support (commit id -'4e17ff79' and 'fbcbd1b2'). With a global setting though, if somehow -the IOThread value in the cgroup hierarchy was set "outside of libvirt" -to a value that is incompatible with the global value. - -Allowing control over IOThread specific values provides the capability -to alter the IOThread values as necessary. - -(cherry picked from commit 2197ea56d77ad3da2e838115eed71d2ad393a082) -Signed-off-by: John Ferlan ---- - docs/formatdomain.html.in | 25 +++++++++++++ - docs/schemas/domaincommon.rng | 10 ++++++ - include/libvirt/libvirt-domain.h | 32 +++++++++++++++++ - src/conf/domain_conf.c | 42 ++++++++++++++++++++++ - src/conf/domain_conf.h | 2 ++ - tests/qemuxml2argvdata/qemuxml2argv-cputune.xml | 2 ++ - .../qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml | 2 ++ - tools/virsh.pod | 9 ++--- - 8 files changed, 120 insertions(+), 4 deletions(-) - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index c080bdf..5b4f83e 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -665,6 +665,8 @@ - <quota>-1</quota> - <emulator_period>1000000</emulator_period> - <emulator_quota>-1</emulator_quota> -+ <iothread_period>1000000</iothread_period> -+ <iothread_quota>-1</iothread_quota> - <vcpusched vcpus='0-4,^3' scheduler='fifo' priority='1'/> - <iothreadsched iothreads='2' scheduler='batch'/> - </cputune> -@@ -769,6 +771,29 @@ - Only QEMU driver support since 0.10.0 - - -+
iothread_period
-+
-+ The optional iothread_period element specifies the -+ enforcement interval(unit: microseconds) for IOThreads. Within -+ iothread_period, each IOThread of the domain will -+ not be allowed to consume more than iothread_quota -+ worth of runtime. The value should be in range [1000, 1000000]. -+ An iothread_period with value 0 means no value. -+ Only QEMU driver support since 2.1.0 -+
-+
iothread_quota
-+
-+ The optional iothread_quota element specifies the maximum -+ allowed bandwidth(unit: microseconds) for IOThreads. A domain with -+ iothread_quota as any negative value indicates that the -+ domain IOThreads have infinite bandwidth, which means that it is -+ not bandwidth controlled. The value should be in range -+ [1000, 18446744073709551] or less than 0. An iothread_quota -+ with value 0 means no value. You can use this feature to ensure that -+ all IOThreads run at the same speed. -+ Only QEMU driver support since 2.1.0 -+
-+ -
vcpusched and iothreadsched
-
- The optional vcpusched elements specifies the scheduler -diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index bf4d795..44e39c8 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -764,6 +764,16 @@ - - - -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - - -diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h -index 7ea93aa..af3ecae 100644 ---- a/include/libvirt/libvirt-domain.h -+++ b/include/libvirt/libvirt-domain.h -@@ -365,6 +365,22 @@ typedef enum { - # define VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA "emulator_quota" - - /** -+ * VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD: -+ * -+ * Macro represents the enforcement period for a quota, in microseconds, -+ * for IOThreads only, when using the posix scheduler, as a ullong. -+ */ -+# define VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD "iothread_period" -+ -+/** -+ * VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA: -+ * -+ * Macro represents the maximum bandwidth to be used within a period for -+ * IOThreads only, when using the posix scheduler, as an llong. -+ */ -+# define VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA "iothread_quota" -+ -+/** - * VIR_DOMAIN_SCHEDULER_WEIGHT: - * - * Macro represents the relative weight, when using the credit -@@ -3604,6 +3620,22 @@ typedef void (*virConnectDomainEventJobCompletedCallback)(virConnectPtr conn, - # define VIR_DOMAIN_TUNABLE_CPU_EMULATOR_QUOTA "cputune.emulator_quota" - - /** -+ * VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD: -+ * -+ * Macro represents the enforcement period for a quota, in microseconds, for -+ * iothreads only, when using the posix scheduler, as VIR_TYPED_PARAM_ULLONG. -+ */ -+# define VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD "cputune.iothread_period" -+ -+/** -+ * VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA: -+ * -+ * Macro represents the maximum bandwidth to be used within a period for -+ * iothreads only, when using the posix scheduler, as VIR_TYPED_PARAM_LLONG. -+ */ -+# define VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA "cputune.iothread_quota" -+ -+/** - * VIR_DOMAIN_TUNABLE_BLKDEV_DISK: - * - * Macro represents the name of guest disk for which the values are updated, -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 261684e..67c7971 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -16343,6 +16343,38 @@ virDomainDefParseXML(xmlDocPtr xml, - goto error; - } - -+ if (virXPathULongLong("string(./cputune/iothread_period[1])", ctxt, -+ &def->cputune.iothread_period) < -1) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("can't parse cputune iothread period value")); -+ goto error; -+ } -+ -+ if (def->cputune.iothread_period > 0 && -+ (def->cputune.iothread_period < 1000 || -+ def->cputune.iothread_period > 1000000)) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("Value of cputune iothread_period must be in range " -+ "[1000, 1000000]")); -+ goto error; -+ } -+ -+ if (virXPathLongLong("string(./cputune/iothread_quota[1])", ctxt, -+ &def->cputune.iothread_quota) < -1) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("can't parse cputune iothread quota value")); -+ goto error; -+ } -+ -+ if (def->cputune.iothread_quota > 0 && -+ (def->cputune.iothread_quota < 1000 || -+ def->cputune.iothread_quota > 18446744073709551LL)) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("Value of cputune iothread_quota must be in range " -+ "[1000, 18446744073709551]")); -+ goto error; -+ } -+ - if ((n = virXPathNodeSet("./cputune/vcpupin", ctxt, &nodes)) < 0) - goto error; - -@@ -22975,6 +23007,16 @@ virDomainCputuneDefFormat(virBufferPtr buf, - "\n", - def->cputune.emulator_quota); - -+ if (def->cputune.iothread_period) -+ virBufferAsprintf(&childrenBuf, "%llu" -+ "\n", -+ def->cputune.iothread_period); -+ -+ if (def->cputune.iothread_quota) -+ virBufferAsprintf(&childrenBuf, "%lld" -+ "\n", -+ def->cputune.iothread_quota); -+ - for (i = 0; i < def->maxvcpus; i++) { - char *cpumask; - virDomainVcpuDefPtr vcpu = def->vcpus[i]; -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 34da54c..61ca8bd 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2031,6 +2031,8 @@ struct _virDomainCputune { - long long global_quota; - unsigned long long emulator_period; - long long emulator_quota; -+ unsigned long long iothread_period; -+ long long iothread_quota; - virBitmapPtr emulatorpin; - }; - -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml b/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml -index 9595903..e6ef51d 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml -+++ b/tests/qemuxml2argvdata/qemuxml2argv-cputune.xml -@@ -10,6 +10,8 @@ - -1 - 1000000 - -1 -+ 1000000 -+ -1 - - - -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml -index baf1779..7a1f50d 100644 ---- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-cputune.xml -@@ -10,6 +10,8 @@ - -1 - 1000000 - -1 -+ 1000000 -+ -1 - - - -diff --git a/tools/virsh.pod b/tools/virsh.pod -index 601cb44..5fef86b 100644 ---- a/tools/virsh.pod -+++ b/tools/virsh.pod -@@ -1906,7 +1906,7 @@ available for each hypervisor are: - LXC (posix scheduler) : cpu_shares, vcpu_period, vcpu_quota - - QEMU/KVM (posix scheduler): cpu_shares, vcpu_period, vcpu_quota, --emulator_period, emulator_quota -+emulator_period, emulator_quota, iothread_quota, iothread_period - - Xen (credit scheduler): weight, cap - -@@ -1924,9 +1924,10 @@ values 0 and 1 are automatically converted to a minimal value of 2. - B: The weight and cap parameters are defined only for the - XEN_CREDIT scheduler and are now I. - --B: The vcpu_period/emulator_period parameters have a valid value range --of 1000-1000000 or 0, and the vcpu_quota/emulator_quota parameters have a --valid value range of 1000-18446744073709551 or less than 0. The value 0 for -+B: The vcpu_period, emulator_period, and iothread_period parameters -+have a valid value range of 1000-1000000 or 0, and the vcpu_quota, -+emulator_quota, and iothread_quota parameters have a valid value range of -+1000-18446744073709551 or less than 0. The value 0 for - either parameter is the same as not specifying that parameter. - - =item B I [I] [I<--screen> B] --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Add-XML-for-individual-vCPU-hotplug.patch b/SOURCES/libvirt-conf-Add-XML-for-individual-vCPU-hotplug.patch deleted file mode 100644 index c243c3b..0000000 --- a/SOURCES/libvirt-conf-Add-XML-for-individual-vCPU-hotplug.patch +++ /dev/null @@ -1,471 +0,0 @@ -From c9fb2f1ef7a756909c705df0c6a323af826be139 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:11:33 -0400 -Subject: [PATCH] conf: Add XML for individual vCPU hotplug - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Individual vCPU hotplug requires us to track the state of any vCPU. To -allow this add the following XML: - - - ... - 3 - - - - - - ... - -The 'enabled' attribute allows to control the state of the vcpu. -'hotpluggable' controls whether given vcpu can be hotplugged and 'order' -allows to specify the order to add the vcpus. - -(cherry picked from commit 5847bc5c64f205a2f00315a2434e8a7bd48c5508) ---- - docs/formatdomain.html.in | 40 ++++++ - docs/schemas/domaincommon.rng | 25 ++++ - src/conf/domain_conf.c | 154 ++++++++++++++++++++- - src/conf/domain_conf.h | 6 + - src/qemu/qemu_domain.c | 11 +- - .../generic-vcpus-individual.xml | 23 +++ - tests/genericxml2xmltest.c | 2 + - tests/testutils.c | 4 +- - 8 files changed, 261 insertions(+), 4 deletions(-) - create mode 100644 tests/genericxml2xmlindata/generic-vcpus-individual.xml - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index b74057f..252f91c 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -489,6 +489,10 @@ - <domain> - ... - <vcpu placement='static' cpuset="1-4,^3,6" current="1">2</vcpu> -+ <vcpus> -+ <vcpu id='0' enabled='yes' hotpluggable='no' order='1'/> -+ <vcpu id='1' enabled='no' hotpluggable='yes'/> -+ </vcpus> - ... - </domain> - -@@ -542,6 +546,42 @@ -
- - -+
vcpus
-+
-+ The vcpus element allows to control state of individual vcpus. -+ -+ The id attribute specifies the vCPU id as used by libvirt -+ in other places such as vcpu pinning, scheduler information and NUMA -+ assignment. Note that the vcpu ID as seen in the guest may differ from -+ libvirt ID in certain cases. Valid IDs are from 0 to the maximum vcpu -+ count as set by the vcpu element minus 1. -+ -+ The enabled attribute allows to control the state of the -+ vcpu. Valid values are yes and no. -+ -+ hotpluggable controls whether given vcpu can be hotplugged -+ and hotunplugged in cases when the cpu is enabled at boot. Note that -+ all disabled vcpus must be hotpluggable. Valid values are -+ yes and no. -+ -+ order allows to specify the order to add the vcpus. For -+ hypervisors/platforms that require to insert multiple vcpus at once -+ the order may be be duplicated accross all vcpus that need to be -+ enabled at once. Specifying order is not necessary, vcpus are then -+ added in an arbitrary order. -+ -+ Note that hypervisors may create hotpluggable vcpus differently from -+ boot vcpus thus special initialization may be necessary. -+ -+ Hypervisors may require that vcpus enabled on boot which are not -+ hotpluggable are clustered at the beginning starting with ID 0. It may -+ be also required that vcpu 0 is always present and non-hotpluggable. -+ -+ Note that providing state for individual cpus may be necessary to enable -+ support of addressable vCPU hotplug and this feature may not be -+ supported by all hypervisors. -+ Since 2.2.0 (QEMU only) -+
- - -

IOThreads Allocation

-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index 497597c..bf4d795 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -583,6 +583,31 @@ - - - -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 4e703d9..d3a0400 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -4425,6 +4425,13 @@ virDomainDefPostParseCheckFeatures(virDomainDefPtr def, - } - } - -+ if (UNSUPPORTED(VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS) && -+ def->individualvcpus) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("individual CPU state configuration is not supported")); -+ return -1; -+ } -+ - return 0; - } - -@@ -4499,6 +4506,43 @@ virDomainDefPostParseDeviceIterator(virDomainDefPtr def, - - - static int -+virDomainVcpuDefPostParse(virDomainDefPtr def) -+{ -+ virDomainVcpuDefPtr vcpu; -+ size_t maxvcpus = virDomainDefGetVcpusMax(def); -+ size_t i; -+ -+ for (i = 0; i < maxvcpus; i++) { -+ vcpu = virDomainDefGetVcpu(def, i); -+ -+ switch (vcpu->hotpluggable) { -+ case VIR_TRISTATE_BOOL_ABSENT: -+ if (vcpu->online) -+ vcpu->hotpluggable = VIR_TRISTATE_BOOL_NO; -+ else -+ vcpu->hotpluggable = VIR_TRISTATE_BOOL_YES; -+ break; -+ -+ case VIR_TRISTATE_BOOL_NO: -+ if (!vcpu->online) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("vcpu '%zu' is both offline and not " -+ "hotpluggable"), i); -+ return -1; -+ } -+ break; -+ -+ case VIR_TRISTATE_BOOL_YES: -+ case VIR_TRISTATE_BOOL_LAST: -+ break; -+ } -+ } -+ -+ return 0; -+} -+ -+ -+static int - virDomainDefPostParseInternal(virDomainDefPtr def, - struct virDomainDefPostParseDeviceIteratorData *data) - { -@@ -4509,6 +4553,9 @@ virDomainDefPostParseInternal(virDomainDefPtr def, - return -1; - } - -+ if (virDomainVcpuDefPostParse(def) < 0) -+ return -1; -+ - if (virDomainDefPostParseMemory(def, data->parseFlags) < 0) - return -1; - -@@ -15590,6 +15637,8 @@ virDomainVcpuParse(virDomainDefPtr def, - virDomainXMLOptionPtr xmlopt) - { - int n; -+ xmlNodePtr *nodes = NULL; -+ size_t i; - char *tmp = NULL; - unsigned int maxvcpus; - unsigned int vcpus; -@@ -15618,8 +15667,6 @@ virDomainVcpuParse(virDomainDefPtr def, - vcpus = maxvcpus; - } - -- if (virDomainDefSetVcpus(def, vcpus) < 0) -- goto cleanup; - - tmp = virXPathString("string(./vcpu[1]/@placement)", ctxt); - if (tmp) { -@@ -15651,9 +15698,82 @@ virDomainVcpuParse(virDomainDefPtr def, - } - } - -+ if ((n = virXPathNodeSet("./vcpus/vcpu", ctxt, &nodes)) < 0) -+ goto cleanup; -+ -+ if (n) { -+ /* if individual vcpu states are provided take them as master */ -+ def->individualvcpus = true; -+ -+ for (i = 0; i < n; i++) { -+ virDomainVcpuDefPtr vcpu; -+ int state; -+ unsigned int id; -+ unsigned int order; -+ -+ if (!(tmp = virXMLPropString(nodes[i], "id")) || -+ virStrToLong_uip(tmp, NULL, 10, &id) < 0) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("missing or invalid vcpu id")); -+ goto cleanup; -+ } -+ -+ VIR_FREE(tmp); -+ -+ if (id >= def->maxvcpus) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("vcpu id '%u' is out of range of maximum " -+ "vcpu count"), id); -+ goto cleanup; -+ } -+ -+ vcpu = virDomainDefGetVcpu(def, id); -+ -+ if (!(tmp = virXMLPropString(nodes[i], "enabled"))) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("missing vcpu enabled state")); -+ goto cleanup; -+ } -+ -+ if ((state = virTristateBoolTypeFromString(tmp)) < 0) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("invalid vcpu 'enabled' value '%s'"), tmp); -+ goto cleanup; -+ } -+ VIR_FREE(tmp); -+ -+ vcpu->online = state == VIR_TRISTATE_BOOL_YES; -+ -+ if ((tmp = virXMLPropString(nodes[i], "hotpluggable"))) { -+ int hotpluggable; -+ if ((hotpluggable = virTristateBoolTypeFromString(tmp)) < 0) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("invalid vcpu 'hotpluggable' value '%s'"), tmp); -+ goto cleanup; -+ } -+ vcpu->hotpluggable = hotpluggable; -+ VIR_FREE(tmp); -+ } -+ -+ if ((tmp = virXMLPropString(nodes[i], "order"))) { -+ if (virStrToLong_uip(tmp, NULL, 10, &order) < 0) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("invalid vcpu order")); -+ goto cleanup; -+ } -+ vcpu->order = order; -+ VIR_FREE(tmp); -+ } -+ } -+ } else { -+ if (virDomainDefSetVcpus(def, vcpus) < 0) -+ goto cleanup; -+ } -+ - ret = 0; - - cleanup: -+ VIR_FREE(nodes); - VIR_FREE(tmp); - - return ret; -@@ -18679,6 +18799,13 @@ virDomainDefVcpuCheckAbiStability(virDomainDefPtr src, - "destination definitions"), i); - return false; - } -+ -+ if (svcpu->order != dvcpu->order) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("vcpu enable order of vCPU '%zu' differs between " -+ "source and destination definitions"), i); -+ return false; -+ } - } - - return true; -@@ -22921,6 +23048,8 @@ static int - virDomainCpuDefFormat(virBufferPtr buf, - const virDomainDef *def) - { -+ virDomainVcpuDefPtr vcpu; -+ size_t i; - char *cpumask = NULL; - int ret = -1; - -@@ -22937,6 +23066,27 @@ virDomainCpuDefFormat(virBufferPtr buf, - virBufferAsprintf(buf, " current='%u'", virDomainDefGetVcpus(def)); - virBufferAsprintf(buf, ">%u\n", virDomainDefGetVcpusMax(def)); - -+ if (def->individualvcpus) { -+ virBufferAddLit(buf, "\n"); -+ virBufferAdjustIndent(buf, 2); -+ for (i = 0; i < def->maxvcpus; i++) { -+ vcpu = def->vcpus[i]; -+ -+ virBufferAsprintf(buf, "online ? "yes" : "no"); -+ if (vcpu->hotpluggable) -+ virBufferAsprintf(buf, " hotpluggable='%s'", -+ virTristateBoolTypeToString(vcpu->hotpluggable)); -+ -+ if (vcpu->order != 0) -+ virBufferAsprintf(buf, " order='%d'", vcpu->order); -+ -+ virBufferAddLit(buf, "/>\n"); -+ } -+ virBufferAdjustIndent(buf, -2); -+ virBufferAddLit(buf, "\n"); -+ } -+ - ret = 0; - - cleanup: -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index e7ff401..34da54c 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2040,6 +2040,9 @@ typedef virDomainVcpuDef *virDomainVcpuDefPtr; - - struct _virDomainVcpuDef { - bool online; -+ virTristateBool hotpluggable; -+ unsigned int order; -+ - virBitmapPtr cpumask; - - virDomainThreadSchedParam sched; -@@ -2136,6 +2139,8 @@ struct _virDomainDef { - - virDomainVcpuDefPtr *vcpus; - size_t maxvcpus; -+ /* set if the vcpu definition was specified individually */ -+ bool individualvcpus; - int placement_mode; - virBitmapPtr cpumask; - -@@ -2338,6 +2343,7 @@ typedef enum { - VIR_DOMAIN_DEF_FEATURE_MEMORY_HOTPLUG = (1 << 1), - VIR_DOMAIN_DEF_FEATURE_OFFLINE_VCPUPIN = (1 << 2), - VIR_DOMAIN_DEF_FEATURE_NAME_SLASH = (1 << 3), -+ VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS = (1 << 4), - } virDomainDefFeatures; - - -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index add8379..7a71bfb 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -5796,8 +5796,17 @@ qemuDomainRefreshVcpuInfo(virQEMUDriverPtr driver, - VIR_STEAL_PTR(vcpupriv->alias, info[i].alias); - vcpupriv->enable_id = info[i].id; - -- if (hotplug && state) -+ if (hotplug && state) { - vcpu->online = !!info[i].qom_path; -+ -+ /* mark cpus that don't have an alias as non-hotpluggable */ -+ if (vcpu->online) { -+ if (vcpupriv->alias) -+ vcpu->hotpluggable = VIR_TRISTATE_BOOL_YES; -+ else -+ vcpu->hotpluggable = VIR_TRISTATE_BOOL_NO; -+ } -+ } - } - - ret = 0; -diff --git a/tests/genericxml2xmlindata/generic-vcpus-individual.xml b/tests/genericxml2xmlindata/generic-vcpus-individual.xml -new file mode 100644 -index 0000000..cbcf8fd ---- /dev/null -+++ b/tests/genericxml2xmlindata/generic-vcpus-individual.xml -@@ -0,0 +1,23 @@ -+ -+ foobar -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 4 -+ -+ -+ -+ -+ -+ -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ -+ -diff --git a/tests/genericxml2xmltest.c b/tests/genericxml2xmltest.c -index a487727..2ea2396 100644 ---- a/tests/genericxml2xmltest.c -+++ b/tests/genericxml2xmltest.c -@@ -97,6 +97,8 @@ mymain(void) - - DO_TEST("perf"); - -+ DO_TEST("vcpus-individual"); -+ - virObjectUnref(caps); - virObjectUnref(xmlopt); - -diff --git a/tests/testutils.c b/tests/testutils.c -index be61e4d..2daad43 100644 ---- a/tests/testutils.c -+++ b/tests/testutils.c -@@ -1075,7 +1075,9 @@ virCapsPtr virTestGenericCapsInit(void) - return NULL; - } - --static virDomainDefParserConfig virTestGenericDomainDefParserConfig; -+static virDomainDefParserConfig virTestGenericDomainDefParserConfig = { -+ .features = VIR_DOMAIN_DEF_FEATURE_INDIVIDUAL_VCPUS, -+}; - static virDomainXMLPrivateDataCallbacks virTestGenericPrivateDataCallbacks; - - virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void) --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Add-check-for-non-scsi_host-parent-during-vport-delete.patch b/SOURCES/libvirt-conf-Add-check-for-non-scsi_host-parent-during-vport-delete.patch new file mode 100644 index 0000000..66afa80 --- /dev/null +++ b/SOURCES/libvirt-conf-Add-check-for-non-scsi_host-parent-during-vport-delete.patch @@ -0,0 +1,46 @@ +From aa337656da6b3e44ccaae85ec64538dee80000cf Mon Sep 17 00:00:00 2001 +Message-Id: +From: John Ferlan +Date: Thu, 13 Apr 2017 10:38:35 -0400 +Subject: [PATCH] conf: Add check for non scsi_host parent during vport delete + +https://bugzilla.redhat.com/show_bug.cgi?id=1420740 + +If the parent is not a scsi_host, then we can just happily return since +we won't be removing a vport. + +Fixes a bug with the following output: + +$ virsh pool-destroy host4_hba_pool +error: Failed to destroy pool host4_hba_pool +error: internal error: Invalid adapter name 'pci_0000_10_00_1' for SCSI pool + +$ + +(cherry picked from commit 84f178bdc7ab38011cc1f76759b0a41335285a4f) +Signed-off-by: John Ferlan +--- + src/conf/node_device_conf.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 7d0baa9d1..cc3fad8b9 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -2074,6 +2074,13 @@ virNodeDeviceDeleteVport(virConnectPtr conn, + if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name))) + goto cleanup; + ++ /* If the parent is not a scsi_host, then this is a pool backed ++ * directly to an HBA and there's no vHBA to remove - so we're done */ ++ if (!STRPREFIX(vhba_parent, "scsi_host")) { ++ ret = 0; ++ goto cleanup; ++ } ++ + if (virSCSIHostGetNumber(vhba_parent, &parent_host) < 0) + goto cleanup; + } +-- +2.12.2 + diff --git a/SOURCES/libvirt-conf-Add-private-data-for-virDomainVcpuDef.patch b/SOURCES/libvirt-conf-Add-private-data-for-virDomainVcpuDef.patch deleted file mode 100644 index f1a291f..0000000 --- a/SOURCES/libvirt-conf-Add-private-data-for-virDomainVcpuDef.patch +++ /dev/null @@ -1,598 +0,0 @@ -From cb7f9ed96f81aebcade2c42cbdb1bacf97bb611b Mon Sep 17 00:00:00 2001 -Message-Id: -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:10:48 -0400 -Subject: [PATCH] conf: Add private data for virDomainVcpuDef - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Allow to store driver specific data on a per-vcpu basis. - -Move of the virDomainDef*Vcpus* functions was necessary as -virDomainXMLOptionPtr was declared below this block and I didn't want to -split the function headers. - -(cherry picked from commit 5fe0b6b0a7e0c900ab51927ee859c2c92cc92e5d) - - Conflicts: - src/bhyve/bhyve_parse_command.c: file missing ---- - src/conf/domain_conf.c | 30 ++++++++++++++++++++++-------- - src/conf/domain_conf.h | 22 ++++++++++++++-------- - src/hyperv/hyperv_driver.c | 3 ++- - src/libxl/libxl_driver.c | 4 ++-- - src/lxc/lxc_native.c | 2 +- - src/openvz/openvz_conf.c | 2 +- - src/openvz/openvz_driver.c | 16 ++++++++++------ - src/phyp/phyp_driver.c | 2 +- - src/qemu/qemu_driver.c | 2 +- - src/qemu/qemu_parse_command.c | 9 +++++---- - src/test/test_driver.c | 4 +++- - src/vbox/vbox_common.c | 4 ++-- - src/vmx/vmx.c | 2 +- - src/vz/vz_sdk.c | 7 ++++--- - src/xen/xm_internal.c | 2 +- - src/xenapi/xenapi_driver.c | 2 +- - src/xenconfig/xen_common.c | 13 ++++++++----- - src/xenconfig/xen_common.h | 3 ++- - src/xenconfig/xen_sxpr.c | 2 +- - src/xenconfig/xen_xl.c | 3 ++- - src/xenconfig/xen_xm.c | 3 ++- - 21 files changed, 86 insertions(+), 51 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 6d0f967..384059d 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -1313,12 +1313,23 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def) - - - static virDomainVcpuDefPtr --virDomainVcpuDefNew(void) -+virDomainVcpuDefNew(virDomainXMLOptionPtr xmlopt) - { -- virDomainVcpuDefPtr ret; -+ virObjectPtr priv = NULL; -+ virDomainVcpuDefPtr ret = NULL; - -- ignore_value(VIR_ALLOC(ret)); -+ if (xmlopt && xmlopt->privateData.vcpuNew && -+ !(priv = xmlopt->privateData.vcpuNew())) -+ goto cleanup; - -+ if (VIR_ALLOC(ret) < 0) -+ goto cleanup; -+ -+ ret->privateData = priv; -+ priv = NULL; -+ -+ cleanup: -+ virObjectUnref(priv); - return ret; - } - -@@ -1331,13 +1342,15 @@ virDomainVcpuDefFree(virDomainVcpuDefPtr info) - - virBitmapFree(info->cpumask); - info->cpumask = NULL; -+ virObjectUnref(info->privateData); - VIR_FREE(info); - } - - - int - virDomainDefSetVcpusMax(virDomainDefPtr def, -- unsigned int maxvcpus) -+ unsigned int maxvcpus, -+ virDomainXMLOptionPtr xmlopt) - { - size_t oldmax = def->maxvcpus; - size_t i; -@@ -1350,7 +1363,7 @@ virDomainDefSetVcpusMax(virDomainDefPtr def, - return -1; - - for (i = oldmax; i < def->maxvcpus; i++) { -- if (!(def->vcpus[i] = virDomainVcpuDefNew())) -+ if (!(def->vcpus[i] = virDomainVcpuDefNew(xmlopt))) - return -1; - } - } else { -@@ -15569,7 +15582,8 @@ virDomainIOThreadSchedParse(xmlNodePtr node, - - static int - virDomainVcpuParse(virDomainDefPtr def, -- xmlXPathContextPtr ctxt) -+ xmlXPathContextPtr ctxt, -+ virDomainXMLOptionPtr xmlopt) - { - int n; - char *tmp = NULL; -@@ -15587,7 +15601,7 @@ virDomainVcpuParse(virDomainDefPtr def, - maxvcpus = 1; - } - -- if (virDomainDefSetVcpusMax(def, maxvcpus) < 0) -+ if (virDomainDefSetVcpusMax(def, maxvcpus, xmlopt) < 0) - goto cleanup; - - if ((n = virXPathUInt("string(./vcpu[1]/@current)", ctxt, &vcpus)) < 0) { -@@ -16056,7 +16070,7 @@ virDomainDefParseXML(xmlDocPtr xml, - &def->mem.swap_hard_limit) < 0) - goto error; - -- if (virDomainVcpuParse(def, ctxt) < 0) -+ if (virDomainVcpuParse(def, ctxt, xmlopt) < 0) - goto error; - - /* Optional - iothreads */ -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index ac37382..e7ff401 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2043,6 +2043,8 @@ struct _virDomainVcpuDef { - virBitmapPtr cpumask; - - virDomainThreadSchedParam sched; -+ -+ virObjectPtr privateData; - }; - - typedef struct _virDomainBlkiotune virDomainBlkiotune; -@@ -2261,14 +2263,6 @@ struct _virDomainDef { - xmlNodePtr metadata; - }; - --int virDomainDefSetVcpusMax(virDomainDefPtr def, unsigned int vcpus); --bool virDomainDefHasVcpusOffline(const virDomainDef *def); --unsigned int virDomainDefGetVcpusMax(const virDomainDef *def); --int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus); --unsigned int virDomainDefGetVcpus(const virDomainDef *def); --virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def); --virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu) -- ATTRIBUTE_RETURN_CHECK; - - unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def); - void virDomainDefSetMemoryTotal(virDomainDefPtr def, unsigned long long size); -@@ -2422,6 +2416,7 @@ struct _virDomainXMLPrivateDataCallbacks { - virDomainXMLPrivateDataFreeFunc free; - virDomainXMLPrivateDataNewFunc diskNew; - virDomainXMLPrivateDataNewFunc hostdevNew; -+ virDomainXMLPrivateDataNewFunc vcpuNew; - virDomainXMLPrivateDataFormatFunc format; - virDomainXMLPrivateDataParseFunc parse; - }; -@@ -2453,6 +2448,17 @@ virDomainObjIsActive(virDomainObjPtr dom) - return dom->def->id != -1; - } - -+int virDomainDefSetVcpusMax(virDomainDefPtr def, -+ unsigned int vcpus, -+ virDomainXMLOptionPtr xmlopt); -+bool virDomainDefHasVcpusOffline(const virDomainDef *def); -+unsigned int virDomainDefGetVcpusMax(const virDomainDef *def); -+int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus); -+unsigned int virDomainDefGetVcpus(const virDomainDef *def); -+virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def); -+virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu) -+ ATTRIBUTE_RETURN_CHECK; -+ - virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps) - ATTRIBUTE_NONNULL(1); - -diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c -index 9c7faf0..b642a02 100644 ---- a/src/hyperv/hyperv_driver.c -+++ b/src/hyperv/hyperv_driver.c -@@ -876,7 +876,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) - def->mem.cur_balloon = memorySettingData->data->VirtualQuantity * 1024; /* megabyte to kilobyte */ - - if (virDomainDefSetVcpusMax(def, -- processorSettingData->data->VirtualQuantity) < 0) -+ processorSettingData->data->VirtualQuantity, -+ NULL) < 0) - goto cleanup; - - if (virDomainDefSetVcpus(def, -diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c -index be6017a..711e801 100644 ---- a/src/libxl/libxl_driver.c -+++ b/src/libxl/libxl_driver.c -@@ -557,7 +557,7 @@ libxlAddDom0(libxlDriverPrivatePtr driver) - def = NULL; - - virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED); -- if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1)) -+ if (virDomainDefSetVcpusMax(vm->def, d_info.vcpu_max_id + 1, driver->xmlopt)) - goto cleanup; - - if (virDomainDefSetVcpus(vm->def, d_info.vcpu_online) < 0) -@@ -2152,7 +2152,7 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, - - switch (flags) { - case VIR_DOMAIN_VCPU_MAXIMUM | VIR_DOMAIN_VCPU_CONFIG: -- if (virDomainDefSetVcpusMax(def, nvcpus) < 0) -+ if (virDomainDefSetVcpusMax(def, nvcpus, driver->xmlopt) < 0) - goto cleanup; - break; - -diff --git a/src/lxc/lxc_native.c b/src/lxc/lxc_native.c -index acbc20b..a34204e 100644 ---- a/src/lxc/lxc_native.c -+++ b/src/lxc/lxc_native.c -@@ -1020,7 +1020,7 @@ lxcParseConfigString(const char *config, - - /* Value not handled by the LXC driver, setting to - * minimum required to make XML parsing pass */ -- if (virDomainDefSetVcpusMax(vmdef, 1) < 0) -+ if (virDomainDefSetVcpusMax(vmdef, 1, xmlopt) < 0) - goto error; - - if (virDomainDefSetVcpus(vmdef, 1) < 0) -diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c -index 50f4902..99ce95c 100644 ---- a/src/openvz/openvz_conf.c -+++ b/src/openvz/openvz_conf.c -@@ -572,7 +572,7 @@ int openvzLoadDomains(struct openvz_driver *driver) - if (ret == 0 || vcpus == 0) - vcpus = openvzGetNodeCPUs(); - -- if (virDomainDefSetVcpusMax(def, vcpus) < 0) -+ if (virDomainDefSetVcpusMax(def, vcpus, driver->xmlopt) < 0) - goto cleanup; - - if (virDomainDefSetVcpus(def, vcpus) < 0) -diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c -index 48c264b..78c91da 100644 ---- a/src/openvz/openvz_driver.c -+++ b/src/openvz/openvz_driver.c -@@ -70,7 +70,8 @@ static int openvzGetProcessInfo(unsigned long long *cpuTime, int vpsid); - static int openvzConnectGetMaxVcpus(virConnectPtr conn, const char *type); - static int openvzDomainGetMaxVcpus(virDomainPtr dom); - static int openvzDomainSetVcpusInternal(virDomainObjPtr vm, -- unsigned int nvcpus); -+ unsigned int nvcpus, -+ virDomainXMLOptionPtr xmlopt); - static int openvzDomainSetMemoryInternal(virDomainObjPtr vm, - unsigned long long memory); - static int openvzGetVEStatus(virDomainObjPtr vm, int *status, int *reason); -@@ -1032,7 +1033,8 @@ openvzDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int fla - goto cleanup; - } - if (virDomainDefGetVcpusMax(vm->def)) { -- if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def)) < 0) { -+ if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def), -+ driver->xmlopt) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not set number of vCPUs")); - goto cleanup; -@@ -1130,7 +1132,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, - virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_BOOTED); - - if (virDomainDefGetVcpusMax(vm->def) > 0) { -- if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def)) < 0) { -+ if (openvzDomainSetVcpusInternal(vm, virDomainDefGetVcpusMax(vm->def), -+ driver->xmlopt) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not set number of vCPUs")); - goto cleanup; -@@ -1347,7 +1350,8 @@ static int openvzDomainGetMaxVcpus(virDomainPtr dom) - } - - static int openvzDomainSetVcpusInternal(virDomainObjPtr vm, -- unsigned int nvcpus) -+ unsigned int nvcpus, -+ virDomainXMLOptionPtr xmlopt) - { - char str_vcpus[32]; - const char *prog[] = { VZCTL, "--quiet", "set", PROGRAM_SENTINEL, -@@ -1364,7 +1368,7 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm, - if (virRun(prog, NULL) < 0) - return -1; - -- if (virDomainDefSetVcpusMax(vm->def, nvcpus) < 0) -+ if (virDomainDefSetVcpusMax(vm->def, nvcpus, xmlopt) < 0) - return -1; - - if (virDomainDefSetVcpus(vm->def, nvcpus) < 0) -@@ -1402,7 +1406,7 @@ static int openvzDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, - goto cleanup; - } - -- if (openvzDomainSetVcpusInternal(vm, nvcpus) < 0) { -+ if (openvzDomainSetVcpusInternal(vm, nvcpus, driver->xmlopt) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not set number of vCPUs")); - goto cleanup; -diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c -index dce20bc..3dd8927 100644 ---- a/src/phyp/phyp_driver.c -+++ b/src/phyp/phyp_driver.c -@@ -3296,7 +3296,7 @@ phypDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) - goto err; - } - -- if (virDomainDefSetVcpusMax(&def, vcpus) < 0) -+ if (virDomainDefSetVcpusMax(&def, vcpus, phyp_driver->xmlopt) < 0) - goto err; - - if (virDomainDefSetVcpus(&def, vcpus) < 0) -diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index 71f2fb6..d3cf267 100644 ---- a/src/qemu/qemu_driver.c -+++ b/src/qemu/qemu_driver.c -@@ -4863,7 +4863,7 @@ qemuDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, - goto endjob; - } - -- if (virDomainDefSetVcpusMax(persistentDef, nvcpus) < 0) -+ if (virDomainDefSetVcpusMax(persistentDef, nvcpus, driver->xmlopt) < 0) - goto endjob; - } else { - if (virDomainDefSetVcpus(persistentDef, nvcpus) < 0) -diff --git a/src/qemu/qemu_parse_command.c b/src/qemu/qemu_parse_command.c -index b1d8a1d..0bcd1ad 100644 ---- a/src/qemu/qemu_parse_command.c -+++ b/src/qemu/qemu_parse_command.c -@@ -1659,7 +1659,8 @@ qemuParseCommandLineMem(virDomainDefPtr dom, - - static int - qemuParseCommandLineSmp(virDomainDefPtr dom, -- const char *val) -+ const char *val, -+ virDomainXMLOptionPtr xmlopt) - { - unsigned int sockets = 0; - unsigned int cores = 0; -@@ -1701,7 +1702,7 @@ qemuParseCommandLineSmp(virDomainDefPtr dom, - if (maxcpus == 0) - maxcpus = vcpus; - -- if (virDomainDefSetVcpusMax(dom, maxcpus) < 0) -+ if (virDomainDefSetVcpusMax(dom, maxcpus, xmlopt) < 0) - goto error; - - if (virDomainDefSetVcpus(dom, vcpus) < 0) -@@ -1819,7 +1820,7 @@ qemuParseCommandLine(virCapsPtr caps, - def->id = -1; - def->mem.cur_balloon = 64 * 1024; - virDomainDefSetMemoryTotal(def, def->mem.cur_balloon); -- if (virDomainDefSetVcpusMax(def, 1) < 0) -+ if (virDomainDefSetVcpusMax(def, 1, xmlopt) < 0) - goto error; - if (virDomainDefSetVcpus(def, 1) < 0) - goto error; -@@ -1899,7 +1900,7 @@ qemuParseCommandLine(virCapsPtr caps, - goto error; - } else if (STREQ(arg, "-smp")) { - WANT_VALUE(); -- if (qemuParseCommandLineSmp(def, val) < 0) -+ if (qemuParseCommandLineSmp(def, val, xmlopt) < 0) - goto error; - } else if (STREQ(arg, "-uuid")) { - WANT_VALUE(); -diff --git a/src/test/test_driver.c b/src/test/test_driver.c -index e7bca81..36bbd7f 100644 ---- a/src/test/test_driver.c -+++ b/src/test/test_driver.c -@@ -2336,6 +2336,7 @@ static int - testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus, - unsigned int flags) - { -+ testDriverPtr driver = domain->conn->privateData; - virDomainObjPtr privdom = NULL; - virDomainDefPtr def; - virDomainDefPtr persistentDef; -@@ -2383,7 +2384,8 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus, - - if (persistentDef) { - if (flags & VIR_DOMAIN_VCPU_MAXIMUM) { -- if (virDomainDefSetVcpusMax(persistentDef, nrCpus) < 0) -+ if (virDomainDefSetVcpusMax(persistentDef, nrCpus, -+ driver->xmlopt) < 0) - goto cleanup; - } else { - if (virDomainDefSetVcpus(persistentDef, nrCpus) < 0) -diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c -index 8e49268..a14ab67 100644 ---- a/src/vbox/vbox_common.c -+++ b/src/vbox/vbox_common.c -@@ -3885,7 +3885,7 @@ static char *vboxDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) - virDomainDefSetMemoryTotal(def, memorySize * 1024); - - gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount); -- if (virDomainDefSetVcpusMax(def, CPUCount) < 0) -+ if (virDomainDefSetVcpusMax(def, CPUCount, data->xmlopt) < 0) - goto cleanup; - - if (virDomainDefSetVcpus(def, CPUCount) < 0) -@@ -6044,7 +6044,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, - def->dom->os.type = VIR_DOMAIN_OSTYPE_HVM; - def->dom->os.arch = virArchFromHost(); - gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount); -- if (virDomainDefSetVcpusMax(def->dom, CPUCount) < 0) -+ if (virDomainDefSetVcpusMax(def->dom, CPUCount, data->xmlopt) < 0) - goto cleanup; - - if (virDomainDefSetVcpus(def->dom, CPUCount) < 0) -diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c -index d443dd0..0f557a8 100644 ---- a/src/vmx/vmx.c -+++ b/src/vmx/vmx.c -@@ -1457,7 +1457,7 @@ virVMXParseConfig(virVMXContext *ctx, - goto cleanup; - } - -- if (virDomainDefSetVcpusMax(def, numvcpus) < 0) -+ if (virDomainDefSetVcpusMax(def, numvcpus, xmlopt) < 0) - goto cleanup; - - if (virDomainDefSetVcpus(def, numvcpus) < 0) -diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c -index 9d0bc0d..7871230 100644 ---- a/src/vz/vz_sdk.c -+++ b/src/vz/vz_sdk.c -@@ -1309,7 +1309,8 @@ prlsdkConvertDomainState(VIRTUAL_MACHINE_STATE domainState, - - static int - prlsdkConvertCpuInfo(PRL_HANDLE sdkdom, -- virDomainDefPtr def) -+ virDomainDefPtr def, -+ virDomainXMLOptionPtr xmlopt) - { - char *buf; - int hostcpus; -@@ -1327,7 +1328,7 @@ prlsdkConvertCpuInfo(PRL_HANDLE sdkdom, - if (cpuCount > hostcpus) - cpuCount = hostcpus; - -- if (virDomainDefSetVcpusMax(def, cpuCount) < 0) -+ if (virDomainDefSetVcpusMax(def, cpuCount, xmlopt) < 0) - goto cleanup; - - if (virDomainDefSetVcpus(def, cpuCount) < 0) -@@ -1706,7 +1707,7 @@ prlsdkLoadDomain(vzDriverPtr driver, virDomainObjPtr dom) - convert to Kbytes */ - def->mem.cur_balloon = ram << 10; - -- if (prlsdkConvertCpuInfo(sdkdom, def) < 0) -+ if (prlsdkConvertCpuInfo(sdkdom, def, driver->xmlopt) < 0) - goto error; - - if (prlsdkConvertCpuMode(sdkdom, def) < 0) -diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c -index 3c34652..8335078 100644 ---- a/src/xen/xm_internal.c -+++ b/src/xen/xm_internal.c -@@ -700,7 +700,7 @@ xenXMDomainSetVcpusFlags(virConnectPtr conn, - } - - if (flags & VIR_DOMAIN_VCPU_MAXIMUM) { -- if (virDomainDefSetVcpusMax(entry->def, vcpus) < 0) -+ if (virDomainDefSetVcpusMax(entry->def, vcpus, priv->xmlopt) < 0) - goto cleanup; - } else { - if (virDomainDefSetVcpus(entry->def, vcpus) < 0) -diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c -index 676ed5b..9a861c1 100644 ---- a/src/xenapi/xenapi_driver.c -+++ b/src/xenapi/xenapi_driver.c -@@ -1505,7 +1505,7 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) - - vcpus = xenapiDomainGetMaxVcpus(dom); - -- if (virDomainDefSetVcpusMax(defPtr, vcpus) < 0) -+ if (virDomainDefSetVcpusMax(defPtr, vcpus, priv->xmlopt) < 0) - goto error; - - if (virDomainDefSetVcpus(defPtr, vcpus) < 0) -diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c -index f62a5b1..8365a2c 100644 ---- a/src/xenconfig/xen_common.c -+++ b/src/xenconfig/xen_common.c -@@ -483,7 +483,9 @@ xenParsePCI(virConfPtr conf, virDomainDefPtr def) - - - static int --xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def) -+xenParseCPUFeatures(virConfPtr conf, -+ virDomainDefPtr def, -+ virDomainXMLOptionPtr xmlopt) - { - unsigned long count = 0; - const char *str = NULL; -@@ -492,7 +494,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def) - if (xenConfigGetULong(conf, "vcpus", &count, 1) < 0) - return -1; - -- if (virDomainDefSetVcpusMax(def, count) < 0) -+ if (virDomainDefSetVcpusMax(def, count, xmlopt) < 0) - return -1; - - if (virDomainDefSetVcpus(def, count) < 0) -@@ -502,7 +504,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def) - if (xenConfigGetULong(conf, "maxvcpus", &count, 0) < 0) - return -1; - -- if (virDomainDefSetVcpusMax(def, count) < 0) -+ if (virDomainDefSetVcpusMax(def, count, xmlopt) < 0) - return -1; - } - -@@ -1051,7 +1053,8 @@ int - xenParseConfigCommon(virConfPtr conf, - virDomainDefPtr def, - virCapsPtr caps, -- const char *nativeFormat) -+ const char *nativeFormat, -+ virDomainXMLOptionPtr xmlopt) - { - if (xenParseGeneralMeta(conf, def, caps) < 0) - return -1; -@@ -1062,7 +1065,7 @@ xenParseConfigCommon(virConfPtr conf, - if (xenParseEventsActions(conf, def) < 0) - return -1; - -- if (xenParseCPUFeatures(conf, def) < 0) -+ if (xenParseCPUFeatures(conf, def, xmlopt) < 0) - return -1; - - if (xenParseTimeOffset(conf, def) < 0) -diff --git a/src/xenconfig/xen_common.h b/src/xenconfig/xen_common.h -index 1c74bee..9055692 100644 ---- a/src/xenconfig/xen_common.h -+++ b/src/xenconfig/xen_common.h -@@ -59,7 +59,8 @@ int xenConfigCopyStringOpt(virConfPtr conf, - int xenParseConfigCommon(virConfPtr conf, - virDomainDefPtr def, - virCapsPtr caps, -- const char *nativeFormat); -+ const char *nativeFormat, -+ virDomainXMLOptionPtr xmlopt); - - int xenFormatConfigCommon(virConfPtr conf, - virDomainDefPtr def, -diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c -index ea6c177..40dc53c 100644 ---- a/src/xenconfig/xen_sxpr.c -+++ b/src/xenconfig/xen_sxpr.c -@@ -1233,7 +1233,7 @@ xenParseSxpr(const struct sexpr *root, - } - } - -- if (virDomainDefSetVcpusMax(def, sexpr_int(root, "domain/vcpus")) < 0) -+ if (virDomainDefSetVcpusMax(def, sexpr_int(root, "domain/vcpus"), xmlopt) < 0) - goto error; - - vcpus = count_one_bits_l(sexpr_u64(root, "domain/vcpu_avail")); -diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c -index f8cebd2..25a3621 100644 ---- a/src/xenconfig/xen_xl.c -+++ b/src/xenconfig/xen_xl.c -@@ -594,7 +594,8 @@ xenParseXL(virConfPtr conf, - def->virtType = VIR_DOMAIN_VIRT_XEN; - def->id = -1; - -- if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XL) < 0) -+ if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XL, -+ xmlopt) < 0) - goto cleanup; - - if (xenParseXLOS(conf, def, caps) < 0) -diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c -index 1023ed2..124c94a 100644 ---- a/src/xenconfig/xen_xm.c -+++ b/src/xenconfig/xen_xm.c -@@ -447,7 +447,8 @@ xenParseXM(virConfPtr conf, - def->virtType = VIR_DOMAIN_VIRT_XEN; - def->id = -1; - -- if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XM) < 0) -+ if (xenParseConfigCommon(conf, def, caps, XEN_CONFIG_FORMAT_XM, -+ xmlopt) < 0) - goto cleanup; - - if (xenParseXMOS(conf, def) < 0) --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Add-save-cookie-callbacks-to-xmlopt.patch b/SOURCES/libvirt-conf-Add-save-cookie-callbacks-to-xmlopt.patch new file mode 100644 index 0000000..d7101a8 --- /dev/null +++ b/SOURCES/libvirt-conf-Add-save-cookie-callbacks-to-xmlopt.patch @@ -0,0 +1,427 @@ +From 7cf2eee78e7e0e08eb1203f7fdb5705aba6b0e42 Mon Sep 17 00:00:00 2001 +Message-Id: <7cf2eee78e7e0e08eb1203f7fdb5705aba6b0e42@dist-git> +From: Jiri Denemark +Date: Fri, 2 Jun 2017 00:44:46 +0200 +Subject: [PATCH] conf: Add save cookie callbacks to xmlopt + +virDomainXMLOption gains driver specific callbacks for parsing and +formatting save cookies. + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit 25af7e950a9e35a6cffeed32bbcdd95dd7e01035) + +https://bugzilla.redhat.com/show_bug.cgi?id=1441662 + +Signed-off-by: Jiri Denemark +--- + src/bhyve/bhyve_domain.c | 2 +- + src/conf/domain_conf.c | 16 +++++++++++++++- + src/conf/domain_conf.h | 7 ++++++- + src/conf/snapshot_conf.c | 11 ++++++++++- + src/conf/snapshot_conf.h | 2 ++ + src/libvirt_private.syms | 1 + + src/libxl/libxl_conf.c | 2 +- + src/lxc/lxc_conf.c | 2 +- + src/openvz/openvz_driver.c | 2 +- + src/phyp/phyp_driver.c | 2 +- + src/qemu/qemu_capabilities.c | 2 +- + src/qemu/qemu_conf.c | 3 ++- + src/security/virt-aa-helper.c | 2 +- + src/test/test_driver.c | 2 +- + src/uml/uml_driver.c | 2 +- + src/vbox/vbox_common.c | 2 +- + src/vmware/vmware_driver.c | 3 ++- + src/vmx/vmx.c | 2 +- + src/vz/vz_driver.c | 2 +- + src/xen/xen_driver.c | 2 +- + src/xenapi/xenapi_driver.c | 2 +- + tests/bhyveargv2xmltest.c | 2 +- + tests/testutils.c | 2 +- + 23 files changed, 54 insertions(+), 21 deletions(-) + +diff --git a/src/bhyve/bhyve_domain.c b/src/bhyve/bhyve_domain.c +index 0a99550afa..20c82937b5 100644 +--- a/src/bhyve/bhyve_domain.c ++++ b/src/bhyve/bhyve_domain.c +@@ -144,7 +144,7 @@ virBhyveDriverCreateXMLConf(bhyveConnPtr driver) + virBhyveDriverDomainDefParserConfig.priv = driver; + return virDomainXMLOptionNew(&virBhyveDriverDomainDefParserConfig, + &virBhyveDriverPrivateDataCallbacks, +- NULL, NULL); ++ NULL, NULL, NULL); + } + + virDomainDefParserConfig virBhyveDriverDomainDefParserConfig = { +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 395dcc0531..b473ce6b1e 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -79,6 +79,9 @@ struct _virDomainXMLOption { + + /* ABI stability callbacks */ + virDomainABIStability abi; ++ ++ /* Private data for save image stored in snapshot XML */ ++ virSaveCookieCallbacks saveCookie; + }; + + #define VIR_DOMAIN_DEF_FORMAT_COMMON_FLAGS \ +@@ -1054,7 +1057,8 @@ virDomainXMLOptionPtr + virDomainXMLOptionNew(virDomainDefParserConfigPtr config, + virDomainXMLPrivateDataCallbacksPtr priv, + virDomainXMLNamespacePtr xmlns, +- virDomainABIStabilityPtr abi) ++ virDomainABIStabilityPtr abi, ++ virSaveCookieCallbacksPtr saveCookie) + { + virDomainXMLOptionPtr xmlopt; + +@@ -1076,6 +1080,9 @@ virDomainXMLOptionNew(virDomainDefParserConfigPtr config, + if (abi) + xmlopt->abi = *abi; + ++ if (saveCookie) ++ xmlopt->saveCookie = *saveCookie; ++ + /* Technically this forbids to use one of Xerox's MAC address prefixes in + * our hypervisor drivers. This shouldn't ever be a problem. + * +@@ -1106,6 +1113,13 @@ virDomainXMLOptionGetNamespace(virDomainXMLOptionPtr xmlopt) + } + + ++virSaveCookieCallbacksPtr ++virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt) ++{ ++ return &xmlopt->saveCookie; ++} ++ ++ + void + virBlkioDeviceArrayClear(virBlkioDevicePtr devices, + int ndevices) +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index d64ef1b6e9..706d106ad9 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -55,6 +55,7 @@ + # include "virgic.h" + # include "virperf.h" + # include "virtypedparam.h" ++# include "virsavecookie.h" + + /* forward declarations of all device types, required by + * virDomainDeviceDef +@@ -2549,7 +2550,11 @@ struct _virDomainABIStability { + virDomainXMLOptionPtr virDomainXMLOptionNew(virDomainDefParserConfigPtr config, + virDomainXMLPrivateDataCallbacksPtr priv, + virDomainXMLNamespacePtr xmlns, +- virDomainABIStabilityPtr abi); ++ virDomainABIStabilityPtr abi, ++ virSaveCookieCallbacksPtr saveCookie); ++ ++virSaveCookieCallbacksPtr ++virDomainXMLOptionGetSaveCookie(virDomainXMLOptionPtr xmlopt); + + void virDomainNetGenerateMAC(virDomainXMLOptionPtr xmlopt, virMacAddrPtr mac); + +diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c +index e3bba985d7..6330f7d1f9 100644 +--- a/src/conf/snapshot_conf.c ++++ b/src/conf/snapshot_conf.c +@@ -102,6 +102,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def) + virDomainSnapshotDiskDefClear(&def->disks[i]); + VIR_FREE(def->disks); + virDomainDefFree(def->dom); ++ virObjectUnref(def->cookie); + VIR_FREE(def); + } + +@@ -214,6 +215,7 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, + char *memorySnapshot = NULL; + char *memoryFile = NULL; + bool offline = !!(flags & VIR_DOMAIN_SNAPSHOT_PARSE_OFFLINE); ++ virSaveCookieCallbacksPtr saveCookie = virDomainXMLOptionGetSaveCookie(xmlopt); + + if (VIR_ALLOC(def) < 0) + goto cleanup; +@@ -365,6 +367,9 @@ virDomainSnapshotDefParse(xmlXPathContextPtr ctxt, + def->current = active != 0; + } + ++ if (!offline && virSaveCookieParse(ctxt, &def->cookie, saveCookie) < 0) ++ goto cleanup; ++ + ret = def; + + cleanup: +@@ -691,7 +696,7 @@ char * + virDomainSnapshotDefFormat(const char *domain_uuid, + virDomainSnapshotDefPtr def, + virCapsPtr caps, +- virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, ++ virDomainXMLOptionPtr xmlopt, + unsigned int flags, + int internal) + { +@@ -751,6 +756,10 @@ virDomainSnapshotDefFormat(const char *domain_uuid, + virBufferAddLit(&buf, "\n"); + } + ++ if (virSaveCookieFormatBuf(&buf, def->cookie, ++ virDomainXMLOptionGetSaveCookie(xmlopt)) < 0) ++ goto error; ++ + if (internal) + virBufferAsprintf(&buf, "%d\n", def->current); + +diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h +index 2ce526fa6b..1d663c77bc 100644 +--- a/src/conf/snapshot_conf.h ++++ b/src/conf/snapshot_conf.h +@@ -76,6 +76,8 @@ struct _virDomainSnapshotDef { + + virDomainDefPtr dom; + ++ virObjectPtr cookie; ++ + /* Internal use. */ + bool current; /* At most one snapshot in the list should have this set */ + }; +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index b4769080e8..88e3f4b8ac 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -533,6 +533,7 @@ virDomainWatchdogActionTypeToString; + virDomainWatchdogModelTypeFromString; + virDomainWatchdogModelTypeToString; + virDomainXMLOptionGetNamespace; ++virDomainXMLOptionGetSaveCookie; + virDomainXMLOptionNew; + + +diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c +index dd345c22cf..28d31db158 100644 +--- a/src/libxl/libxl_conf.c ++++ b/src/libxl/libxl_conf.c +@@ -2147,5 +2147,5 @@ libxlCreateXMLConf(void) + { + return virDomainXMLOptionNew(&libxlDomainDefParserConfig, + &libxlDomainXMLPrivateDataCallbacks, +- NULL, NULL); ++ NULL, NULL, NULL); + } +diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c +index b46fbc58ff..8adc408c32 100644 +--- a/src/lxc/lxc_conf.c ++++ b/src/lxc/lxc_conf.c +@@ -213,7 +213,7 @@ lxcDomainXMLConfInit(void) + return virDomainXMLOptionNew(&virLXCDriverDomainDefParserConfig, + &virLXCDriverPrivateDataCallbacks, + &virLXCDriverDomainXMLNamespace, +- NULL); ++ NULL, NULL); + } + + +diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c +index 44a6631a99..4392aa64c0 100644 +--- a/src/openvz/openvz_driver.c ++++ b/src/openvz/openvz_driver.c +@@ -1493,7 +1493,7 @@ static virDrvOpenStatus openvzConnectOpen(virConnectPtr conn, + goto cleanup; + + if (!(driver->xmlopt = virDomainXMLOptionNew(&openvzDomainDefParserConfig, +- NULL, NULL, NULL))) ++ NULL, NULL, NULL, NULL))) + goto cleanup; + + if (openvzLoadDomains(driver) < 0) +diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c +index e85f66ffab..32cb681c75 100644 +--- a/src/phyp/phyp_driver.c ++++ b/src/phyp/phyp_driver.c +@@ -1199,7 +1199,7 @@ phypConnectOpen(virConnectPtr conn, + goto failure; + + if (!(phyp_driver->xmlopt = virDomainXMLOptionNew(&virPhypDriverDomainDefParserConfig, +- NULL, NULL, NULL))) ++ NULL, NULL, NULL, NULL))) + goto failure; + + conn->privateData = phyp_driver; +diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c +index 72d3f25763..29bb9949af 100644 +--- a/src/qemu/qemu_capabilities.c ++++ b/src/qemu/qemu_capabilities.c +@@ -5027,7 +5027,7 @@ virQEMUCapsInitQMPCommandRun(virQEMUCapsInitQMPCommandPtr cmd, + goto ignore; + } + +- if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL)) || ++ if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) || + !(cmd->vm = virDomainObjNew(xmlopt))) + goto cleanup; + +diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c +index 76eed25277..96956b7779 100644 +--- a/src/qemu/qemu_conf.c ++++ b/src/qemu/qemu_conf.c +@@ -908,7 +908,8 @@ virQEMUDriverCreateXMLConf(virQEMUDriverPtr driver) + return virDomainXMLOptionNew(&virQEMUDriverDomainDefParserConfig, + &virQEMUDriverPrivateDataCallbacks, + &virQEMUDriverDomainXMLNamespace, +- &virQEMUDriverDomainABIStability); ++ &virQEMUDriverDomainABIStability, ++ NULL); + } + + +diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c +index 48201d5b8c..97436e5dc7 100644 +--- a/src/security/virt-aa-helper.c ++++ b/src/security/virt-aa-helper.c +@@ -667,7 +667,7 @@ get_definition(vahControl * ctl, const char *xmlStr) + goto exit; + } + +- if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL))) { ++ if (!(ctl->xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL))) { + vah_error(ctl, 0, _("Failed to create XML config object")); + goto exit; + } +diff --git a/src/test/test_driver.c b/src/test/test_driver.c +index c8085dd797..4fd14ddee6 100644 +--- a/src/test/test_driver.c ++++ b/src/test/test_driver.c +@@ -414,7 +414,7 @@ testDriverNew(void) + goto error; + } + +- if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL)) || ++ if (!(ret->xmlopt = virDomainXMLOptionNew(NULL, NULL, &ns, NULL, NULL)) || + !(ret->eventState = virObjectEventStateNew()) || + !(ret->domains = virDomainObjListNew()) || + !(ret->networks = virNetworkObjListNew())) +diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c +index ae75daa596..f91ee2961e 100644 +--- a/src/uml/uml_driver.c ++++ b/src/uml/uml_driver.c +@@ -533,7 +533,7 @@ umlStateInitialize(bool privileged, + goto out_of_memory; + + if (!(uml_driver->xmlopt = virDomainXMLOptionNew(¨DriverDomainDefParserConfig, +- &privcb, NULL, NULL))) ++ &privcb, NULL, NULL, NULL))) + goto error; + + if ((uml_driver->inotifyFD = inotify_init()) < 0) { +diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c +index c739031660..4a79c43a1a 100644 +--- a/src/vbox/vbox_common.c ++++ b/src/vbox/vbox_common.c +@@ -139,7 +139,7 @@ vboxDriverObjNew(void) + + if (!(driver->caps = vboxCapsInit()) || + !(driver->xmlopt = virDomainXMLOptionNew(&vboxDomainDefParserConfig, +- NULL, NULL, NULL))) ++ NULL, NULL, NULL, NULL))) + goto cleanup; + + return driver; +diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c +index 24e97a4969..525c85edc8 100644 +--- a/src/vmware/vmware_driver.c ++++ b/src/vmware/vmware_driver.c +@@ -114,7 +114,8 @@ vmwareDomainXMLConfigInit(void) + virDomainXMLPrivateDataCallbacks priv = { .alloc = vmwareDataAllocFunc, + .free = vmwareDataFreeFunc }; + +- return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, NULL, NULL); ++ return virDomainXMLOptionNew(&vmwareDomainDefParserConfig, &priv, ++ NULL, NULL, NULL); + } + + static virDrvOpenStatus +diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c +index 3289a20026..96507f10f3 100644 +--- a/src/vmx/vmx.c ++++ b/src/vmx/vmx.c +@@ -591,7 +591,7 @@ virDomainXMLOptionPtr + virVMXDomainXMLConfInit(void) + { + return virDomainXMLOptionNew(&virVMXDomainDefParserConfig, NULL, +- &virVMXDomainXMLNamespace, NULL); ++ &virVMXDomainXMLNamespace, NULL, NULL); + } + + char * +diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c +index f0b6722a6e..532a6841f3 100644 +--- a/src/vz/vz_driver.c ++++ b/src/vz/vz_driver.c +@@ -326,7 +326,7 @@ vzDriverObjNew(void) + if (!(driver->caps = vzBuildCapabilities()) || + !(driver->xmlopt = virDomainXMLOptionNew(&vzDomainDefParserConfig, + &vzDomainXMLPrivateDataCallbacksPtr, +- NULL, NULL)) || ++ NULL, NULL, NULL)) || + !(driver->domains = virDomainObjListNew()) || + !(driver->domainEventState = virObjectEventStateNew()) || + (vzInitVersion(driver) < 0) || +diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c +index 0c160f8370..ab74ba9928 100644 +--- a/src/xen/xen_driver.c ++++ b/src/xen/xen_driver.c +@@ -401,7 +401,7 @@ virDomainXMLOptionPtr + xenDomainXMLConfInit(void) + { + return virDomainXMLOptionNew(&xenDomainDefParserConfig, +- NULL, NULL, NULL); ++ NULL, NULL, NULL, NULL); + } + + +diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c +index 5623ddb507..c94fd422f9 100644 +--- a/src/xenapi/xenapi_driver.c ++++ b/src/xenapi/xenapi_driver.c +@@ -200,7 +200,7 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, + } + + if (!(privP->xmlopt = virDomainXMLOptionNew(&xenapiDomainDefParserConfig, +- NULL, NULL, NULL))) { ++ NULL, NULL, NULL, NULL))) { + xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, + _("Failed to create XML conf object")); + goto error; +diff --git a/tests/bhyveargv2xmltest.c b/tests/bhyveargv2xmltest.c +index 5d7261a45b..43ef76a594 100644 +--- a/tests/bhyveargv2xmltest.c ++++ b/tests/bhyveargv2xmltest.c +@@ -131,7 +131,7 @@ mymain(void) + return EXIT_FAILURE; + + if ((driver.xmlopt = virDomainXMLOptionNew(NULL, NULL, +- NULL, NULL)) == NULL) ++ NULL, NULL, NULL)) == NULL) + return EXIT_FAILURE; + + # define DO_TEST_FULL(name, flags) \ +diff --git a/tests/testutils.c b/tests/testutils.c +index b7dc8d8408..0823469068 100644 +--- a/tests/testutils.c ++++ b/tests/testutils.c +@@ -1136,7 +1136,7 @@ virDomainXMLOptionPtr virTestGenericDomainXMLConfInit(void) + { + return virDomainXMLOptionNew(&virTestGenericDomainDefParserConfig, + &virTestGenericPrivateDataCallbacks, +- NULL, NULL); ++ NULL, NULL, NULL); + } + + +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-Add-some-shmem-helpers-for-future-use.patch b/SOURCES/libvirt-conf-Add-some-shmem-helpers-for-future-use.patch deleted file mode 100644 index 2fbbfaf..0000000 --- a/SOURCES/libvirt-conf-Add-some-shmem-helpers-for-future-use.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 378bfb59a59c8b029c95f538fee46262a2c72116 Mon Sep 17 00:00:00 2001 -Message-Id: <378bfb59a59c8b029c95f538fee46262a2c72116@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:44 +0100 -Subject: [PATCH] conf: Add some shmem helpers for future use - -Signed-off-by: Martin Kletzander -(cherry picked from commit e5568193f4d663f6a9edebcf9044d527f90a031f) - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/conf/domain_conf.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ - src/conf/domain_conf.h | 9 ++++++ - src/libvirt_private.syms | 5 ++++ - 3 files changed, 89 insertions(+) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 415ab1c..57d5ec8 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -14831,6 +14831,81 @@ virDomainRedirdevDefRemove(virDomainDefPtr def, size_t idx) - } - - -+int -+virDomainShmemDefInsert(virDomainDefPtr def, -+ virDomainShmemDefPtr shmem) -+{ -+ return VIR_APPEND_ELEMENT(def->shmems, def->nshmems, shmem); -+} -+ -+ -+bool -+virDomainShmemDefEquals(virDomainShmemDefPtr src, -+ virDomainShmemDefPtr dst) -+{ -+ if (STRNEQ_NULLABLE(src->name, dst->name)) -+ return false; -+ -+ if (src->size != dst->size) -+ return false; -+ -+ if (src->server.enabled != dst->server.enabled) -+ return false; -+ -+ if (src->server.enabled) { -+ if (STRNEQ_NULLABLE(src->server.chr.data.nix.path, -+ dst->server.chr.data.nix.path)) -+ return false; -+ } -+ -+ if (src->msi.enabled != dst->msi.enabled) -+ return false; -+ -+ if (src->msi.enabled) { -+ if (src->msi.vectors != dst->msi.vectors) -+ return false; -+ if (src->msi.ioeventfd != dst->msi.ioeventfd) -+ return false; -+ } -+ -+ if (src->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && -+ !virDomainDeviceInfoAddressIsEqual(&src->info, &dst->info)) -+ return false; -+ -+ return true; -+} -+ -+ -+ssize_t -+virDomainShmemDefFind(virDomainDefPtr def, -+ virDomainShmemDefPtr shmem) -+{ -+ size_t i; -+ -+ for (i = 0; i < def->nshmems; i++) { -+ if (virDomainShmemDefEquals(def->shmems[i], shmem)) -+ break; -+ } -+ -+ if (i < def->nshmems) -+ return i; -+ -+ return -1; -+} -+ -+ -+virDomainShmemDefPtr -+virDomainShmemDefRemove(virDomainDefPtr def, -+ size_t idx) -+{ -+ virDomainShmemDefPtr ret = def->shmems[idx]; -+ -+ VIR_DELETE_ELEMENT(def->shmems, idx, def->nshmems); -+ -+ return ret; -+} -+ -+ - char * - virDomainDefGetDefaultEmulator(virDomainDefPtr def, - virCapsPtr caps) -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index c674796..594982e 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2955,6 +2955,15 @@ int virDomainMemoryFindInactiveByDef(virDomainDefPtr def, - virDomainMemoryDefPtr mem) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; - -+int virDomainShmemDefInsert(virDomainDefPtr def, virDomainShmemDefPtr shmem) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; -+bool virDomainShmemDefEquals(virDomainShmemDefPtr src, virDomainShmemDefPtr dst) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; -+ssize_t virDomainShmemDefFind(virDomainDefPtr def, virDomainShmemDefPtr shmem) -+ ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; -+virDomainShmemDefPtr virDomainShmemDefRemove(virDomainDefPtr def, size_t idx) -+ ATTRIBUTE_NONNULL(1); -+ - VIR_ENUM_DECL(virDomainTaint) - VIR_ENUM_DECL(virDomainVirt) - VIR_ENUM_DECL(virDomainBoot) -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 5878360..9b7c26c 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -455,6 +455,11 @@ virDomainSaveStatus; - virDomainSaveXML; - virDomainSeclabelTypeFromString; - virDomainSeclabelTypeToString; -+virDomainShmemDefEquals; -+virDomainShmemDefFind; -+virDomainShmemDefFree; -+virDomainShmemDefInsert; -+virDomainShmemDefRemove; - virDomainShutdownReasonTypeFromString; - virDomainShutdownReasonTypeToString; - virDomainShutoffReasonTypeFromString; --- -2.10.2 - diff --git a/SOURCES/libvirt-conf-Add-support-for-virtio-net.rx_queue_size.patch b/SOURCES/libvirt-conf-Add-support-for-virtio-net.rx_queue_size.patch deleted file mode 100644 index 8508eae..0000000 --- a/SOURCES/libvirt-conf-Add-support-for-virtio-net.rx_queue_size.patch +++ /dev/null @@ -1,317 +0,0 @@ -From bf9cd171c0979ae6a2eee0bee7841c23c69a1f42 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Michal Privoznik -Date: Sat, 10 Sep 2016 08:25:09 +0200 -Subject: [PATCH] conf: Add support for virtio-net.rx_queue_size - -https://bugzilla.redhat.com/show_bug.cgi?id=1366989 - -QEMU added another virtio-net tunable [1]. It basically allows -users to set the size of RX virtio ring. But because virtio-net -uses two separate ring buffers to pass data from/to guest they -named it explicitly rx_queue_size. We should expose it in our XML -too. - -1: http://lists.nongnu.org/archive/html/qemu-devel/2016-08/msg02029.html - -Conflicts: tests/qemuxml2xmltest.c - there are more tests in -upstream. - -Signed-off-by: Michal Privoznik -(cherry picked from commit c56cdf25935e0e7fe6b0e803d62fec223b9a0df2) -Signed-off-by: Michal Privoznik ---- - docs/formatdomain.html.in | 16 ++++++++- - docs/schemas/domaincommon.rng | 5 +++ - src/conf/domain_conf.c | 16 +++++++++ - src/conf/domain_conf.h | 1 + - src/qemu/qemu_domain.c | 7 ++++ - ...ml2argv-net-virtio-rxqueuesize-invalid-size.xml | 29 +++++++++++++++ - .../qemuxml2argv-net-virtio-rxqueuesize.xml | 29 +++++++++++++++ - tests/qemuxml2argvtest.c | 1 + - .../qemuxml2xmlout-net-virtio-rxqueuesize.xml | 41 ++++++++++++++++++++++ - tests/qemuxml2xmltest.c | 1 + - 10 files changed, 145 insertions(+), 1 deletion(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml - create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index 5b4f83e..4970d61 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -4648,7 +4648,7 @@ qemu-kvm -net nic,model=? /dev/null - <source network='default'/> - <target dev='vnet1'/> - <model type='virtio'/> -- <driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5'> -+ <driver name='vhost' txmode='iothread' ioeventfd='on' event_idx='off' queues='5' rx_queue_size='256'> - <host csum='off' gso='off' tso4='off' tso6='off' ecn='off' ufo='off' mrg_rxbuf='off'/> - <guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/> - </driver> -@@ -4764,6 +4764,20 @@ qemu-kvm -net nic,model=? /dev/null - virtio-net since 1.0.6 (QEMU and KVM only) - vhost-user since 1.2.17 (QEMU and KVM only) - -+
rx_queue_size
-+
-+ The optional rx_queue_size attribute controls -+ the size of virtio ring for each queue as described above. -+ The default value is hypervisor dependent and may change -+ across its releases. Moreover, some hypervisors may pose -+ some restrictions on actual value. For instance, latest -+ QEMU (as of 2016-09-01) requires value to be a power of two -+ from [256, 1024] range. -+ Since 2.3.0 (QEMU and KVM only)

-+ -+ In general you should leave this option alone, unless you -+ are very certain you know what you are doing. -+
- -

- Offloading options for the host and guest can be configured using -diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index 44e39c8..6935b0d 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -2530,6 +2530,11 @@ - - - -+ -+ -+ -+ -+ - - - iothread -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index edf5de2..caa9ce0 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -9059,6 +9059,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, - char *ioeventfd = NULL; - char *event_idx = NULL; - char *queues = NULL; -+ char *rx_queue_size = NULL; - char *str = NULL; - char *filter = NULL; - char *internal = NULL; -@@ -9222,6 +9223,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, - ioeventfd = virXMLPropString(cur, "ioeventfd"); - event_idx = virXMLPropString(cur, "event_idx"); - queues = virXMLPropString(cur, "queues"); -+ rx_queue_size = virXMLPropString(cur, "rx_queue_size"); - } else if (xmlStrEqual(cur->name, BAD_CAST "filterref")) { - if (filter) { - virReportError(VIR_ERR_XML_ERROR, "%s", -@@ -9605,6 +9607,16 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, - if (q > 1) - def->driver.virtio.queues = q; - } -+ if (rx_queue_size) { -+ unsigned int q; -+ if (virStrToLong_uip(rx_queue_size, NULL, 10, &q) < 0) { -+ virReportError(VIR_ERR_XML_DETAIL, -+ _("'rx_queue_size' attribute must be positive number: %s"), -+ rx_queue_size); -+ goto error; -+ } -+ def->driver.virtio.rx_queue_size = q; -+ } - if ((str = virXPathString("string(./driver/host/@csum)", ctxt))) { - if ((val = virTristateSwitchTypeFromString(str)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -@@ -9785,6 +9797,7 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, - VIR_FREE(ioeventfd); - VIR_FREE(event_idx); - VIR_FREE(queues); -+ VIR_FREE(rx_queue_size); - VIR_FREE(str); - VIR_FREE(filter); - VIR_FREE(type); -@@ -20964,6 +20977,9 @@ virDomainVirtioNetDriverFormat(char **outstr, - } - if (def->driver.virtio.queues) - virBufferAsprintf(&buf, "queues='%u' ", def->driver.virtio.queues); -+ if (def->driver.virtio.rx_queue_size) -+ virBufferAsprintf(&buf, "rx_queue_size='%u' ", -+ def->driver.virtio.rx_queue_size); - - virBufferTrim(&buf, " ", -1); - -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 305ae96..c674796 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -903,6 +903,7 @@ struct _virDomainNetDef { - virTristateSwitch ioeventfd; - virTristateSwitch event_idx; - unsigned int queues; /* Multiqueue virtio-net */ -+ unsigned int rx_queue_size; - struct { - virTristateSwitch csum; - virTristateSwitch gso; -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 989baa5..f001c6e 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -2469,6 +2469,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, - "not supported by QEMU")); - goto cleanup; - } -+ -+ if (STREQ_NULLABLE(net->model, "virtio") && -+ net->driver.virtio.rx_queue_size & (net->driver.virtio.rx_queue_size - 1)) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("rx_queue_size has to be a power of two")); -+ goto cleanup; -+ } - } - - ret = 0; -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml -new file mode 100644 -index 0000000..d308bc1 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize-invalid-size.xml -@@ -0,0 +1,29 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219100 -+ 219100 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml -new file mode 100644 -index 0000000..cfb4742 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio-rxqueuesize.xml -@@ -0,0 +1,29 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219100 -+ 219100 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index 9de2f94..f4054e7 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1040,6 +1040,7 @@ mymain(void) - QEMU_CAPS_VIRTIO_S390); - DO_TEST("net-virtio-ccw", - QEMU_CAPS_VIRTIO_CCW, QEMU_CAPS_VIRTIO_S390); -+ DO_TEST_PARSE_ERROR("net-virtio-rxqueuesize-invalid-size", NONE); - DO_TEST("net-eth", NONE); - DO_TEST("net-eth-ifname", NONE); - DO_TEST("net-eth-names", NONE); -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml -new file mode 100644 -index 0000000..5b41936 ---- /dev/null -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-virtio-rxqueuesize.xml -@@ -0,0 +1,41 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219100 -+ 219100 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+

-+ -+ -+
-+ -+ -+ -+
-+ -+ -+ -+ -+ -+
-+ -+ -+ -+ -+
-+ -+ -+ -diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c -index 639494b..5458361 100644 ---- a/tests/qemuxml2xmltest.c -+++ b/tests/qemuxml2xmltest.c -@@ -518,6 +518,7 @@ mymain(void) - DO_TEST("net-eth"); - DO_TEST("net-eth-ifname"); - DO_TEST("net-virtio-network-portgroup"); -+ DO_TEST("net-virtio-rxqueuesize"); - DO_TEST("net-hostdev"); - DO_TEST("net-hostdev-vfio"); - DO_TEST("net-midonet"); --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Allow-copying-of-shmem-defs.patch b/SOURCES/libvirt-conf-Allow-copying-of-shmem-defs.patch deleted file mode 100644 index c85ff2d..0000000 --- a/SOURCES/libvirt-conf-Allow-copying-of-shmem-defs.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 4ee594e8126c8187e933c10f1a24d28df3fd1090 Mon Sep 17 00:00:00 2001 -Message-Id: <4ee594e8126c8187e933c10f1a24d28df3fd1090@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:34 +0100 -Subject: [PATCH] conf: Allow copying of shmem defs - -This way we'll be able to hotplug with both --live and --config in one -API call. - -Signed-off-by: Martin Kletzander -(cherry picked from commit 921ec15fdbf215e74f0898b0b8cf879db63ccb4b) - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/conf/domain_conf.c | 5 ++++- - 1 file changed, 4 insertions(+), 1 deletion(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index caa9ce0..415ab1c 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -25026,11 +25026,14 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, - case VIR_DOMAIN_DEVICE_MEMORY: - rc = virDomainMemoryDefFormat(&buf, src->data.memory, flags); - break; -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ rc = virDomainShmemDefFormat(&buf, src->data.shmem, flags); -+ break; -+ - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: -- case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_IOMMU: - case VIR_DOMAIN_DEVICE_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, --- -2.10.2 - diff --git a/SOURCES/libvirt-conf-Check-CPU-cache-for-ABI-stability.patch b/SOURCES/libvirt-conf-Check-CPU-cache-for-ABI-stability.patch new file mode 100644 index 0000000..13fcb60 --- /dev/null +++ b/SOURCES/libvirt-conf-Check-CPU-cache-for-ABI-stability.patch @@ -0,0 +1,41 @@ +From b768a8cb9fbd84a96f576d1dd7468f664200683f Mon Sep 17 00:00:00 2001 +Message-Id: +From: Jiri Denemark +Date: Wed, 10 May 2017 13:05:16 +0200 +Subject: [PATCH] conf: Check CPU cache for ABI stability + +Signed-off-by: Jiri Denemark +Reviewed-by: Daniel P. Berrange +(cherry picked from commit 1e9cf6e09ce242c94731bd21707dd3bcd41f854f) + +https://bugzilla.redhat.com/show_bug.cgi?id=1449595 + +Signed-off-by: Jiri Denemark +--- + src/conf/cpu_conf.c | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c +index 1b098c476..a4be5742e 100644 +--- a/src/conf/cpu_conf.c ++++ b/src/conf/cpu_conf.c +@@ -915,6 +915,16 @@ virCPUDefIsEqual(virCPUDefPtr src, + } + } + ++ if ((src->cache && !dst->cache) || ++ (!src->cache && dst->cache) || ++ (src->cache && dst->cache && ++ (src->cache->level != dst->cache->level || ++ src->cache->mode != dst->cache->mode))) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", ++ _("Target CPU cache does not match source")); ++ goto cleanup; ++ } ++ + identical = true; + + cleanup: +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-Don-t-assign-value-from-.TypeFromString-directly-to-enum.patch b/SOURCES/libvirt-conf-Don-t-assign-value-from-.TypeFromString-directly-to-enum.patch new file mode 100644 index 0000000..6d2a136 --- /dev/null +++ b/SOURCES/libvirt-conf-Don-t-assign-value-from-.TypeFromString-directly-to-enum.patch @@ -0,0 +1,54 @@ +From 8c00ca78eed4ffdb9238b89b58eb5975baf5e339 Mon Sep 17 00:00:00 2001 +Message-Id: <8c00ca78eed4ffdb9238b89b58eb5975baf5e339@dist-git> +From: Peter Krempa +Date: Fri, 19 May 2017 12:24:11 +0200 +Subject: [PATCH] conf: Don't assign value from ..TypeFromString directly to + enum + +Enums are unsigned, so it's impossible to check whether the helper +returned -1 for invalid conversions. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1452454 +(cherry picked from commit 85d62624c5d02c38e00a275dc2b2957584454908) + +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 1653aa61d..a918ecd59 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -14065,6 +14065,7 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, + xmlNodePtr save = ctxt->node; + xmlNodePtr node; + virDomainMemoryDefPtr def; ++ int val; + + ctxt->node = memdevNode; + +@@ -14084,12 +14085,14 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, + } + VIR_FREE(tmp); + +- tmp = virXMLPropString(memdevNode, "access"); +- if (tmp && +- (def->access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) { +- virReportError(VIR_ERR_XML_ERROR, +- _("invalid access mode '%s'"), tmp); +- goto error; ++ if ((tmp = virXMLPropString(memdevNode, "access"))) { ++ if ((val = virDomainMemoryAccessTypeFromString(tmp)) <= 0) { ++ virReportError(VIR_ERR_XML_ERROR, ++ _("invalid access mode '%s'"), tmp); ++ goto error; ++ } ++ ++ def->access = val; + } + VIR_FREE(tmp); + +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-Don-t-complicate-find-loop.patch b/SOURCES/libvirt-conf-Don-t-complicate-find-loop.patch deleted file mode 100644 index f9cba34..0000000 --- a/SOURCES/libvirt-conf-Don-t-complicate-find-loop.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 5357b85bd1454127075feb039ae1b3c9216fc77e Mon Sep 17 00:00:00 2001 -Message-Id: <5357b85bd1454127075feb039ae1b3c9216fc77e@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:47 +0100 -Subject: [PATCH] conf: Don't complicate find loop - -Signed-off-by: Martin Kletzander -(cherry picked from commit d7107959c3cd9f113158b9165449f9c7d4754113) - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/conf/domain_conf.c | 5 +---- - 1 file changed, 1 insertion(+), 4 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 8afd2b0..25e4ba2 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -14884,12 +14884,9 @@ virDomainShmemDefFind(virDomainDefPtr def, - - for (i = 0; i < def->nshmems; i++) { - if (virDomainShmemDefEquals(shmem, def->shmems[i])) -- break; -+ return i; - } - -- if (i < def->nshmems) -- return i; -- - return -1; - } - --- -2.10.2 - diff --git a/SOURCES/libvirt-conf-Don-t-report-errors-from-virDomainDefGetVcpu.patch b/SOURCES/libvirt-conf-Don-t-report-errors-from-virDomainDefGetVcpu.patch deleted file mode 100644 index 021f218..0000000 --- a/SOURCES/libvirt-conf-Don-t-report-errors-from-virDomainDefGetVcpu.patch +++ /dev/null @@ -1,76 +0,0 @@ -From 5304cda0dc6e8f370a1f80050e03fdc4d6479d06 Mon Sep 17 00:00:00 2001 -Message-Id: <5304cda0dc6e8f370a1f80050e03fdc4d6479d06@dist-git> -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:10:45 -0400 -Subject: [PATCH] conf: Don't report errors from virDomainDefGetVcpu - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Most callers make sure that it's never called with an out of range vCPU. -Every other caller reports a different error explicitly. Drop the error -reporting and clean up some dead code paths. - -(cherry picked from commit 9cc931f0bbfc4529b3d07b4226af7b218624858d) ---- - src/conf/domain_conf.c | 6 +----- - src/qemu/qemu_driver.c | 10 ++-------- - 2 files changed, 3 insertions(+), 13 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index a923b60..7a12462 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -1433,12 +1433,8 @@ virDomainVcpuDefPtr - virDomainDefGetVcpu(virDomainDefPtr def, - unsigned int vcpu) - { -- if (vcpu >= def->maxvcpus) { -- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -- _("vCPU '%u' is not present in domain definition"), -- vcpu); -+ if (vcpu >= def->maxvcpus) - return NULL; -- } - - return &def->vcpus[vcpu]; - } -diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index b4ab095..71f2fb6 100644 ---- a/src/qemu/qemu_driver.c -+++ b/src/qemu/qemu_driver.c -@@ -4620,14 +4620,11 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, - unsigned int vcpu) - { - qemuDomainObjPrivatePtr priv = vm->privateData; -- virDomainVcpuDefPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu); - int ret = -1; - int rc; - int oldvcpus = virDomainDefGetVcpus(vm->def); - -- if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu))) -- return -1; -- - if (vcpuinfo->online) { - virReportError(VIR_ERR_INVALID_ARG, - _("vCPU '%u' is already online"), vcpu); -@@ -4672,14 +4669,11 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, - unsigned int vcpu) - { - qemuDomainObjPrivatePtr priv = vm->privateData; -- virDomainVcpuDefPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu); - int ret = -1; - int rc; - int oldvcpus = virDomainDefGetVcpus(vm->def); - -- if (!(vcpuinfo = virDomainDefGetVcpu(vm->def, vcpu))) -- return -1; -- - if (!vcpuinfo->online) { - virReportError(VIR_ERR_INVALID_ARG, - _("vCPU '%u' is already offline"), vcpu); --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Don-t-validate-vcpu-count-in-XML-parser.patch b/SOURCES/libvirt-conf-Don-t-validate-vcpu-count-in-XML-parser.patch deleted file mode 100644 index 49a1d37..0000000 --- a/SOURCES/libvirt-conf-Don-t-validate-vcpu-count-in-XML-parser.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 892ee6bfd6f0a459b16c9bede5a4af83f76ccd22 Mon Sep 17 00:00:00 2001 -Message-Id: <892ee6bfd6f0a459b16c9bede5a4af83f76ccd22@dist-git> -From: Peter Krempa -Date: Fri, 26 Aug 2016 15:45:26 -0400 -Subject: [PATCH] conf: Don't validate vcpu count in XML parser - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Validating the vcpu count is more intricate and doing it in the XML -parser will make previously valid configs (with older qemus) vanish. - -Now that we have a very similar check in the qemu domain validation -callback we can do it in a more appropriate place. - -This basically reverts commit b54de0830a. - -Partially resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370066 - -(cherry picked from commit c9cb35c255222be7c972f1e049e297517aa84b42) ---- - src/conf/domain_conf.c | 9 --------- - 1 file changed, 9 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index d3a0400..9c49ba7 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -16413,15 +16413,6 @@ virDomainDefParseXML(xmlDocPtr xml, - - if (def->cpu == NULL) - goto error; -- -- if (def->cpu->sockets && -- virDomainDefGetVcpusMax(def) > -- def->cpu->sockets * def->cpu->cores * def->cpu->threads) { -- virReportError(VIR_ERR_XML_DETAIL, "%s", -- _("Maximum CPUs greater than topology limit")); -- goto error; -- } -- - } - - if (virDomainNumaDefCPUParseXML(def->numa, ctxt) < 0) --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Extract-code-formatting-vCPU-info.patch b/SOURCES/libvirt-conf-Extract-code-formatting-vCPU-info.patch deleted file mode 100644 index 3c5634a..0000000 --- a/SOURCES/libvirt-conf-Extract-code-formatting-vCPU-info.patch +++ /dev/null @@ -1,80 +0,0 @@ -From 26aacc4c603cd5f6bd3e4712e768db62c855b600 Mon Sep 17 00:00:00 2001 -Message-Id: <26aacc4c603cd5f6bd3e4712e768db62c855b600@dist-git> -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:10:43 -0400 -Subject: [PATCH] conf: Extract code formatting vCPU info - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -(cherry picked from commit 54f875dc53057ddbde063b941d44442102e424e1) ---- - src/conf/domain_conf.c | 45 +++++++++++++++++++++++++++++++-------------- - 1 file changed, 31 insertions(+), 14 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index ffafef3..9571ee3 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -22885,6 +22885,35 @@ virDomainCputuneDefFormat(virBufferPtr buf, - } - - -+static int -+virDomainCpuDefFormat(virBufferPtr buf, -+ const virDomainDef *def) -+{ -+ char *cpumask = NULL; -+ int ret = -1; -+ -+ virBufferAddLit(buf, "placement_mode)); -+ -+ if (def->cpumask && !virBitmapIsAllSet(def->cpumask)) { -+ if ((cpumask = virBitmapFormat(def->cpumask)) == NULL) -+ goto cleanup; -+ virBufferAsprintf(buf, " cpuset='%s'", cpumask); -+ } -+ if (virDomainDefHasVcpusOffline(def)) -+ virBufferAsprintf(buf, " current='%u'", virDomainDefGetVcpus(def)); -+ virBufferAsprintf(buf, ">%u\n", virDomainDefGetVcpusMax(def)); -+ -+ ret = 0; -+ -+ cleanup: -+ VIR_FREE(cpumask); -+ -+ return ret; -+} -+ -+ - /* This internal version appends to an existing buffer - * (possibly with auto-indent), rather than flattening - * to string. -@@ -23060,20 +23089,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, - virBufferAddLit(buf, "\n"); - } - -- virBufferAddLit(buf, "placement_mode)); -- -- if (def->cpumask && !virBitmapIsAllSet(def->cpumask)) { -- char *cpumask = NULL; -- if ((cpumask = virBitmapFormat(def->cpumask)) == NULL) -- goto error; -- virBufferAsprintf(buf, " cpuset='%s'", cpumask); -- VIR_FREE(cpumask); -- } -- if (virDomainDefHasVcpusOffline(def)) -- virBufferAsprintf(buf, " current='%u'", virDomainDefGetVcpus(def)); -- virBufferAsprintf(buf, ">%u\n", virDomainDefGetVcpusMax(def)); -+ if (virDomainCpuDefFormat(buf, def) < 0) -+ goto error; - - if (def->niothreadids > 0) { - virBufferAsprintf(buf, "%u\n", --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Fix-build-with-picky-GCC.patch b/SOURCES/libvirt-conf-Fix-build-with-picky-GCC.patch deleted file mode 100644 index fa9b21c..0000000 --- a/SOURCES/libvirt-conf-Fix-build-with-picky-GCC.patch +++ /dev/null @@ -1,36 +0,0 @@ -From 70b18a664f73f36641c8b6db8b7ac57715d4f187 Mon Sep 17 00:00:00 2001 -Message-Id: <70b18a664f73f36641c8b6db8b7ac57715d4f187@dist-git> -From: Peter Krempa -Date: Fri, 26 Aug 2016 15:45:28 -0400 -Subject: [PATCH] conf: Fix build with picky GCC - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -../../src/conf/domain_conf.c:4425:21: error: potential null pointer dereference [-Werror=null-dereference] - switch (vcpu->hotpluggable) { - ~~~~^~~~~~~~~~~~~~ - -(cherry picked from commit 9cf086be6d916c52035a0ee89f3f0f020e9fee1f) ---- - src/conf/domain_conf.c | 4 ++++ - 1 file changed, 4 insertions(+) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 9c49ba7..261684e 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -4515,6 +4515,10 @@ virDomainVcpuDefPostParse(virDomainDefPtr def) - for (i = 0; i < maxvcpus; i++) { - vcpu = virDomainDefGetVcpu(def, i); - -+ /* impossible but some compilers don't like it */ -+ if (!vcpu) -+ continue; -+ - switch (vcpu->hotpluggable) { - case VIR_TRISTATE_BOOL_ABSENT: - if (vcpu->online) --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Fix-virDomainShmemDefFind.patch b/SOURCES/libvirt-conf-Fix-virDomainShmemDefFind.patch deleted file mode 100644 index 12b9577..0000000 --- a/SOURCES/libvirt-conf-Fix-virDomainShmemDefFind.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 6ee171e55799c279c776a7dfea6e132f2de5bca5 Mon Sep 17 00:00:00 2001 -Message-Id: <6ee171e55799c279c776a7dfea6e132f2de5bca5@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:46 +0100 -Subject: [PATCH] conf: Fix virDomainShmemDefFind - -Due to the switch of parameters in a call to virDomainShmemDefEquals() -no device was found when looking for device with all the information -except address. Also fix the indentation. - -Signed-off-by: Martin Kletzander -(cherry picked from commit ae612493ffbba8980a31800e260cc5b6b7f456e8) - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/conf/domain_conf.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 57d5ec8..8afd2b0 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -14883,8 +14883,8 @@ virDomainShmemDefFind(virDomainDefPtr def, - size_t i; - - for (i = 0; i < def->nshmems; i++) { -- if (virDomainShmemDefEquals(def->shmems[i], shmem)) -- break; -+ if (virDomainShmemDefEquals(shmem, def->shmems[i])) -+ break; - } - - if (i < def->nshmems) --- -2.10.2 - diff --git a/SOURCES/libvirt-conf-Introduce-virSaveCookie.patch b/SOURCES/libvirt-conf-Introduce-virSaveCookie.patch new file mode 100644 index 0000000..fedfc8b --- /dev/null +++ b/SOURCES/libvirt-conf-Introduce-virSaveCookie.patch @@ -0,0 +1,290 @@ +From 5785b4ff7c33f5e2eb16530f20b6b45d8809aae7 Mon Sep 17 00:00:00 2001 +Message-Id: <5785b4ff7c33f5e2eb16530f20b6b45d8809aae7@dist-git> +From: Jiri Denemark +Date: Fri, 2 Jun 2017 00:44:06 +0200 +Subject: [PATCH] conf: Introduce virSaveCookie + +The code will be used by snapshots and domain save/restore code to store +additional data for a saved running domain. It is analogous to migration +cookies, but simple and one way only. + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit e37daa1fb69ec30042cbc38d489217edb656bc30) + +https://bugzilla.redhat.com/show_bug.cgi?id=1441662 + +Signed-off-by: Jiri Denemark +--- + po/POTFILES.in | 1 + + src/Makefile.am | 1 + + src/conf/virsavecookie.c | 144 +++++++++++++++++++++++++++++++++++++++++++++++ + src/conf/virsavecookie.h | 62 ++++++++++++++++++++ + src/libvirt_private.syms | 7 +++ + 5 files changed, 215 insertions(+) + create mode 100644 src/conf/virsavecookie.c + create mode 100644 src/conf/virsavecookie.h + +diff --git a/po/POTFILES.in b/po/POTFILES.in +index 064abd5bbb..cf64115719 100644 +--- a/po/POTFILES.in ++++ b/po/POTFILES.in +@@ -47,6 +47,7 @@ src/conf/virdomainobjlist.c + src/conf/virinterfaceobj.c + src/conf/virnodedeviceobj.c + src/conf/virnwfilterobj.c ++src/conf/virsavecookie.c + src/conf/virsecretobj.c + src/conf/virstorageobj.c + src/cpu/cpu.c +diff --git a/src/Makefile.am b/src/Makefile.am +index 75e4344198..53550280bf 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -336,6 +336,7 @@ DOMAIN_CONF_SOURCES = \ + conf/domain_conf.c conf/domain_conf.h \ + conf/domain_audit.c conf/domain_audit.h \ + conf/domain_nwfilter.c conf/domain_nwfilter.h \ ++ conf/virsavecookie.c conf/virsavecookie.h \ + conf/snapshot_conf.c conf/snapshot_conf.h \ + conf/numa_conf.c conf/numa_conf.h \ + conf/virdomainobjlist.c conf/virdomainobjlist.h +diff --git a/src/conf/virsavecookie.c b/src/conf/virsavecookie.c +new file mode 100644 +index 0000000000..502c04d0f4 +--- /dev/null ++++ b/src/conf/virsavecookie.c +@@ -0,0 +1,144 @@ ++/** ++ * virsavecookie.c: Save cookie handling ++ * ++ * Copyright (C) 2017 Red Hat, Inc. ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see ++ * . ++ */ ++ ++#include ++ ++#include "virerror.h" ++#include "virlog.h" ++#include "virobject.h" ++#include "virbuffer.h" ++#include "virxml.h" ++#include "virsavecookie.h" ++ ++#define VIR_FROM_THIS VIR_FROM_CONF ++ ++VIR_LOG_INIT("conf.savecookie"); ++ ++ ++static int ++virSaveCookieParseNode(xmlXPathContextPtr ctxt, ++ virObjectPtr *obj, ++ virSaveCookieCallbacksPtr saveCookie) ++{ ++ *obj = NULL; ++ ++ if (!xmlStrEqual(ctxt->node->name, BAD_CAST "cookie")) { ++ virReportError(VIR_ERR_XML_ERROR, "%s", ++ _("XML does not contain expected 'cookie' element")); ++ return -1; ++ } ++ ++ if (!saveCookie || !saveCookie->parse) ++ return 0; ++ ++ return saveCookie->parse(ctxt, obj); ++} ++ ++ ++int ++virSaveCookieParse(xmlXPathContextPtr ctxt, ++ virObjectPtr *obj, ++ virSaveCookieCallbacksPtr saveCookie) ++{ ++ xmlNodePtr node = ctxt->node; ++ int ret = -1; ++ ++ *obj = NULL; ++ ++ if (!(ctxt->node = virXPathNode("./cookie", ctxt))) { ++ ret = 0; ++ goto cleanup; ++ } ++ ++ ret = virSaveCookieParseNode(ctxt, obj, saveCookie); ++ ++ cleanup: ++ ctxt->node = node; ++ return ret; ++} ++ ++ ++int ++virSaveCookieParseString(const char *xml, ++ virObjectPtr *obj, ++ virSaveCookieCallbacksPtr saveCookie) ++{ ++ xmlDocPtr doc = NULL; ++ xmlXPathContextPtr ctxt = NULL; ++ int ret = -1; ++ ++ *obj = NULL; ++ ++ if (!xml) { ++ ret = 0; ++ goto cleanup; ++ } ++ ++ if (!(doc = virXMLParseStringCtxt(xml, _("(save cookie)"), &ctxt))) ++ goto cleanup; ++ ++ ret = virSaveCookieParseNode(ctxt, obj, saveCookie); ++ ++ cleanup: ++ xmlXPathFreeContext(ctxt); ++ xmlFreeDoc(doc); ++ return ret; ++} ++ ++ ++int ++virSaveCookieFormatBuf(virBufferPtr buf, ++ virObjectPtr obj, ++ virSaveCookieCallbacksPtr saveCookie) ++{ ++ if (!obj || !saveCookie || !saveCookie->format) ++ return 0; ++ ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ ++ if (saveCookie->format(buf, obj) < 0) ++ return -1; ++ ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ ++ return 0; ++} ++ ++ ++char * ++virSaveCookieFormat(virObjectPtr obj, ++ virSaveCookieCallbacksPtr saveCookie) ++{ ++ virBuffer buf = VIR_BUFFER_INITIALIZER; ++ ++ if (virSaveCookieFormatBuf(&buf, obj, saveCookie) < 0) ++ goto error; ++ ++ if (virBufferCheckError(&buf) < 0) ++ goto error; ++ ++ return virBufferContentAndReset(&buf); ++ ++ error: ++ virBufferFreeAndReset(&buf); ++ return NULL; ++} +diff --git a/src/conf/virsavecookie.h b/src/conf/virsavecookie.h +new file mode 100644 +index 0000000000..4aed18466c +--- /dev/null ++++ b/src/conf/virsavecookie.h +@@ -0,0 +1,62 @@ ++/** ++ * virsavecookie.h: Save cookie handling ++ * ++ * Copyright (C) 2017 Red Hat, Inc. ++ * ++ * This library is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU Lesser General Public ++ * License as published by the Free Software Foundation; either ++ * version 2.1 of the License, or (at your option) any later version. ++ * ++ * This library is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ++ * Lesser General Public License for more details. ++ * ++ * You should have received a copy of the GNU Lesser General Public ++ * License along with this library. If not, see ++ * . ++ */ ++#ifndef __VIR_SAVE_COOKIE_H__ ++# define __VIR_SAVE_COOKIE_H__ ++ ++# include ++ ++# include "internal.h" ++# include "virobject.h" ++# include "virbuffer.h" ++ ++ ++typedef int (*virSaveCookieParseFunc)(xmlXPathContextPtr ctxt, ++ virObjectPtr *obj); ++typedef int (*virSaveCookieFormatFunc)(virBufferPtr buf, ++ virObjectPtr obj); ++ ++typedef struct _virSaveCookieCallbacks virSaveCookieCallbacks; ++typedef virSaveCookieCallbacks *virSaveCookieCallbacksPtr; ++struct _virSaveCookieCallbacks { ++ virSaveCookieParseFunc parse; ++ virSaveCookieFormatFunc format; ++}; ++ ++ ++int ++virSaveCookieParse(xmlXPathContextPtr ctxt, ++ virObjectPtr *obj, ++ virSaveCookieCallbacksPtr saveCookie); ++ ++int ++virSaveCookieParseString(const char *xml, ++ virObjectPtr *obj, ++ virSaveCookieCallbacksPtr saveCookie); ++ ++int ++virSaveCookieFormatBuf(virBufferPtr buf, ++ virObjectPtr obj, ++ virSaveCookieCallbacksPtr saveCookie); ++ ++char * ++virSaveCookieFormat(virObjectPtr obj, ++ virSaveCookieCallbacksPtr saveCookie); ++ ++#endif /*__VIR_SAVE_COOKIE_H__ */ +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index a578dfba34..b4769080e8 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -971,6 +971,13 @@ virNWFilterObjTestUnassignDef; + virNWFilterObjUnlock; + + ++# conf/virsavecookie.h ++virSaveCookieFormat; ++virSaveCookieFormatBuf; ++virSaveCookieParse; ++virSaveCookieParseString; ++ ++ + # conf/virsecretobj.h + virSecretLoadAllConfigs; + virSecretObjDeleteConfig; +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-Make-error-reporting-in-virCPUDefIsEqual-optional.patch b/SOURCES/libvirt-conf-Make-error-reporting-in-virCPUDefIsEqual-optional.patch new file mode 100644 index 0000000..7e24d8f --- /dev/null +++ b/SOURCES/libvirt-conf-Make-error-reporting-in-virCPUDefIsEqual-optional.patch @@ -0,0 +1,213 @@ +From c1ad40f4ad3813ff3013efba80983f62113fc092 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Jiri Denemark +Date: Wed, 31 May 2017 16:42:42 +0200 +Subject: [PATCH] conf: Make error reporting in virCPUDefIsEqual optional + +The function will be used in paths where mismatching CPU defs are not an +error. + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit 25ec7f6fe959f2811bb014a8c1f0c92bdf9ca13d) + +https://bugzilla.redhat.com/show_bug.cgi?id=1441662 + +Signed-off-by: Jiri Denemark +--- + src/conf/cpu_conf.c | 83 +++++++++++++++++++++++--------------------------- + src/conf/cpu_conf.h | 3 +- + src/conf/domain_conf.c | 2 +- + 3 files changed, 41 insertions(+), 47 deletions(-) + +diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c +index a4be5742e3..ffb2e83d67 100644 +--- a/src/conf/cpu_conf.c ++++ b/src/conf/cpu_conf.c +@@ -811,7 +811,8 @@ virCPUDefAddFeature(virCPUDefPtr def, + + bool + virCPUDefIsEqual(virCPUDefPtr src, +- virCPUDefPtr dst) ++ virCPUDefPtr dst, ++ bool reportError) + { + bool identical = false; + size_t i; +@@ -819,98 +820,89 @@ virCPUDefIsEqual(virCPUDefPtr src, + if (!src && !dst) + return true; + ++#define MISMATCH(fmt, ...) \ ++ if (reportError) \ ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, fmt, __VA_ARGS__) ++ + if ((src && !dst) || (!src && dst)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +- _("Target CPU does not match source")); ++ MISMATCH("%s", _("Target CPU does not match source")); + goto cleanup; + } + + if (src->type != dst->type) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU type %s does not match source %s"), +- virCPUTypeToString(dst->type), +- virCPUTypeToString(src->type)); ++ MISMATCH(_("Target CPU type %s does not match source %s"), ++ virCPUTypeToString(dst->type), ++ virCPUTypeToString(src->type)); + goto cleanup; + } + + if (src->mode != dst->mode) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU mode %s does not match source %s"), +- virCPUModeTypeToString(dst->mode), +- virCPUModeTypeToString(src->mode)); ++ MISMATCH(_("Target CPU mode %s does not match source %s"), ++ virCPUModeTypeToString(dst->mode), ++ virCPUModeTypeToString(src->mode)); + goto cleanup; + } + + if (src->arch != dst->arch) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU arch %s does not match source %s"), +- virArchToString(dst->arch), +- virArchToString(src->arch)); ++ MISMATCH(_("Target CPU arch %s does not match source %s"), ++ virArchToString(dst->arch), ++ virArchToString(src->arch)); + goto cleanup; + } + + if (STRNEQ_NULLABLE(src->model, dst->model)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU model %s does not match source %s"), +- NULLSTR(dst->model), NULLSTR(src->model)); ++ MISMATCH(_("Target CPU model %s does not match source %s"), ++ NULLSTR(dst->model), NULLSTR(src->model)); + goto cleanup; + } + + if (STRNEQ_NULLABLE(src->vendor, dst->vendor)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU vendor %s does not match source %s"), +- NULLSTR(dst->vendor), NULLSTR(src->vendor)); ++ MISMATCH(_("Target CPU vendor %s does not match source %s"), ++ NULLSTR(dst->vendor), NULLSTR(src->vendor)); + goto cleanup; + } + + if (STRNEQ_NULLABLE(src->vendor_id, dst->vendor_id)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU vendor id %s does not match source %s"), +- NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id)); ++ MISMATCH(_("Target CPU vendor id %s does not match source %s"), ++ NULLSTR(dst->vendor_id), NULLSTR(src->vendor_id)); + goto cleanup; + } + + if (src->sockets != dst->sockets) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU sockets %d does not match source %d"), +- dst->sockets, src->sockets); ++ MISMATCH(_("Target CPU sockets %d does not match source %d"), ++ dst->sockets, src->sockets); + goto cleanup; + } + + if (src->cores != dst->cores) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU cores %d does not match source %d"), +- dst->cores, src->cores); ++ MISMATCH(_("Target CPU cores %d does not match source %d"), ++ dst->cores, src->cores); + goto cleanup; + } + + if (src->threads != dst->threads) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU threads %d does not match source %d"), +- dst->threads, src->threads); ++ MISMATCH(_("Target CPU threads %d does not match source %d"), ++ dst->threads, src->threads); + goto cleanup; + } + + if (src->nfeatures != dst->nfeatures) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU feature count %zu does not match source %zu"), +- dst->nfeatures, src->nfeatures); ++ MISMATCH(_("Target CPU feature count %zu does not match source %zu"), ++ dst->nfeatures, src->nfeatures); + goto cleanup; + } + + for (i = 0; i < src->nfeatures; i++) { + if (STRNEQ(src->features[i].name, dst->features[i].name)) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU feature %s does not match source %s"), +- dst->features[i].name, src->features[i].name); ++ MISMATCH(_("Target CPU feature %s does not match source %s"), ++ dst->features[i].name, src->features[i].name); + goto cleanup; + } + + if (src->features[i].policy != dst->features[i].policy) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target CPU feature policy %s does not match source %s"), +- virCPUFeaturePolicyTypeToString(dst->features[i].policy), +- virCPUFeaturePolicyTypeToString(src->features[i].policy)); ++ MISMATCH(_("Target CPU feature policy %s does not match source %s"), ++ virCPUFeaturePolicyTypeToString(dst->features[i].policy), ++ virCPUFeaturePolicyTypeToString(src->features[i].policy)); + goto cleanup; + } + } +@@ -920,11 +912,12 @@ virCPUDefIsEqual(virCPUDefPtr src, + (src->cache && dst->cache && + (src->cache->level != dst->cache->level || + src->cache->mode != dst->cache->mode))) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", +- _("Target CPU cache does not match source")); ++ MISMATCH("%s", _("Target CPU cache does not match source")); + goto cleanup; + } + ++#undef MISMATCH ++ + identical = true; + + cleanup: +diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h +index 09438b68b4..b0d891552a 100644 +--- a/src/conf/cpu_conf.h ++++ b/src/conf/cpu_conf.h +@@ -189,7 +189,8 @@ virCPUDefParseXML(xmlNodePtr node, + + bool + virCPUDefIsEqual(virCPUDefPtr src, +- virCPUDefPtr dst); ++ virCPUDefPtr dst, ++ bool reportError); + + char * + virCPUDefFormat(virCPUDefPtr def, +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index bab85c6362..2197330a22 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -20042,7 +20042,7 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, + goto error; + } + +- if (!virCPUDefIsEqual(src->cpu, dst->cpu)) ++ if (!virCPUDefIsEqual(src->cpu, dst->cpu, true)) + goto error; + + if (!virSysinfoIsEqual(src->sysinfo, dst->sysinfo)) +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-Make-really-sure-we-don-t-access-non-existing-vCPUs-again.patch b/SOURCES/libvirt-conf-Make-really-sure-we-don-t-access-non-existing-vCPUs-again.patch deleted file mode 100644 index 7a12dea..0000000 --- a/SOURCES/libvirt-conf-Make-really-sure-we-don-t-access-non-existing-vCPUs-again.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 295e298a18e91a62cadf756f65de7edc99235b42 Mon Sep 17 00:00:00 2001 -Message-Id: <295e298a18e91a62cadf756f65de7edc99235b42@dist-git> -From: Martin Kletzander -Date: Wed, 24 Aug 2016 16:10:59 -0400 -Subject: [PATCH] conf: Make really sure we don't access non-existing vCPUs - again - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -MinGW complained that we might be dereferencing a NULL pointer. While -that can't be true, the logic certainly allows for that. - -../../src/conf/domain_conf.c: In function 'virDomainDefPostParse': -../../src/conf/domain_conf.c:4224:18: error: potential null pointer dereference [-Werror=null-dereference] - if (!vcpu->online && vcpu->cpumask) { - ~~~~^~~~~~~~ - -Signed-off-by: Daniel P. Berrange -(cherry picked from commit 05f89657eed52550050f9308bb7cb8d56dde9cd0) ---- - src/conf/domain_conf.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 7fa4701..8e5afe7 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -4302,7 +4302,7 @@ virDomainDefRemoveOfflineVcpuPin(virDomainDefPtr def) - for (i = 0; i < virDomainDefGetVcpusMax(def); i++) { - vcpu = virDomainDefGetVcpu(def, i); - -- if (!vcpu->online && vcpu->cpumask) { -+ if (vcpu && !vcpu->online && vcpu->cpumask) { - virBitmapFree(vcpu->cpumask); - vcpu->cpumask = NULL; - --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Make-really-sure-we-don-t-access-non-existing-vCPUs.patch b/SOURCES/libvirt-conf-Make-really-sure-we-don-t-access-non-existing-vCPUs.patch deleted file mode 100644 index 5c95c02..0000000 --- a/SOURCES/libvirt-conf-Make-really-sure-we-don-t-access-non-existing-vCPUs.patch +++ /dev/null @@ -1,39 +0,0 @@ -From e8195e3a489ec211d6d637ddcdae1ca82bef3c7a Mon Sep 17 00:00:00 2001 -Message-Id: -From: Martin Kletzander -Date: Wed, 24 Aug 2016 16:10:58 -0400 -Subject: [PATCH] conf: Make really sure we don't access non-existing vCPUs - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -MinGW complained that we might be dereferencing a NULL pointer. While -that can't be true, the logic certainly allows for that. - -src/conf/domain_conf.c: In function 'virDomainDefGetVcpuPinInfoHelper': -src/conf/domain_conf.c:1545:17: error: potential null pointer dereference [-Werror=null-dereference] - if (vcpu->cpumask) - ~~~~^~~~~~~~~ - -Signed-off-by: Martin Kletzander -(cherry picked from commit a6ab72a9c3ad475a544ffd53a782e46a02437006) ---- - src/conf/domain_conf.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 384059d..7fa4701 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -1544,7 +1544,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, - virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i); - virBitmapPtr bitmap = NULL; - -- if (vcpu->cpumask) -+ if (vcpu && vcpu->cpumask) - bitmap = vcpu->cpumask; - else if (def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO && - autoCpuset) --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Make-virDomainSnapshotDefFormat-easier-to-read.patch b/SOURCES/libvirt-conf-Make-virDomainSnapshotDefFormat-easier-to-read.patch new file mode 100644 index 0000000..5ed7558 --- /dev/null +++ b/SOURCES/libvirt-conf-Make-virDomainSnapshotDefFormat-easier-to-read.patch @@ -0,0 +1,113 @@ +From d1adb920ad7f460e32b1cc68e68120b3c655bc18 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Jiri Denemark +Date: Thu, 1 Jun 2017 15:57:55 +0200 +Subject: [PATCH] conf: Make virDomainSnapshotDefFormat easier to read + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit 00968dca967f4bf9d4f496e5c971bff3f8147ed8) + +https://bugzilla.redhat.com/show_bug.cgi?id=1441662 + +Signed-off-by: Jiri Denemark +--- + src/conf/snapshot_conf.c | 30 +++++++++++++++++++++--------- + 1 file changed, 21 insertions(+), 9 deletions(-) + +diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c +index b6cba5ac38..7daa9b22ad 100644 +--- a/src/conf/snapshot_conf.c ++++ b/src/conf/snapshot_conf.c +@@ -686,11 +686,13 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, + virBufferAddLit(buf, "\n"); + } + +-char *virDomainSnapshotDefFormat(const char *domain_uuid, +- virDomainSnapshotDefPtr def, +- virCapsPtr caps, +- unsigned int flags, +- int internal) ++ ++char * ++virDomainSnapshotDefFormat(const char *domain_uuid, ++ virDomainSnapshotDefPtr def, ++ virCapsPtr caps, ++ unsigned int flags, ++ int internal) + { + virBuffer buf = VIR_BUFFER_INITIALIZER; + size_t i; +@@ -702,12 +704,14 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, + + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); ++ + virBufferEscapeString(&buf, "%s\n", def->name); + if (def->description) + virBufferEscapeString(&buf, "%s\n", + def->description); + virBufferAsprintf(&buf, "%s\n", + virDomainSnapshotStateTypeToString(def->state)); ++ + if (def->parent) { + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); +@@ -715,14 +719,17 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } ++ + virBufferAsprintf(&buf, "%lld\n", + def->creationTime); ++ + if (def->memory) { + virBufferAsprintf(&buf, "memory)); + virBufferEscapeString(&buf, " file='%s'", def->file); + virBufferAddLit(&buf, "/>\n"); + } ++ + if (def->ndisks) { + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); +@@ -731,11 +738,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } ++ + if (def->dom) { +- if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) { +- virBufferFreeAndReset(&buf); +- return NULL; +- } ++ if (virDomainDefFormatInternal(def->dom, caps, flags, &buf) < 0) ++ goto error; + } else if (domain_uuid) { + virBufferAddLit(&buf, "\n"); + virBufferAdjustIndent(&buf, 2); +@@ -743,8 +749,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + } ++ + if (internal) + virBufferAsprintf(&buf, "%d\n", def->current); ++ + virBufferAdjustIndent(&buf, -2); + virBufferAddLit(&buf, "\n"); + +@@ -752,6 +760,10 @@ char *virDomainSnapshotDefFormat(const char *domain_uuid, + return NULL; + + return virBufferContentAndReset(&buf); ++ ++ error: ++ virBufferFreeAndReset(&buf); ++ return NULL; + } + + /* Snapshot Obj functions */ +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-Pass-xmlopt-to-virDomainSnapshotDefFormat.patch b/SOURCES/libvirt-conf-Pass-xmlopt-to-virDomainSnapshotDefFormat.patch new file mode 100644 index 0000000..d546c53 --- /dev/null +++ b/SOURCES/libvirt-conf-Pass-xmlopt-to-virDomainSnapshotDefFormat.patch @@ -0,0 +1,251 @@ +From 49f9421cddc176e39cbb062f26e80ec93341ef0d Mon Sep 17 00:00:00 2001 +Message-Id: <49f9421cddc176e39cbb062f26e80ec93341ef0d@dist-git> +From: Jiri Denemark +Date: Fri, 2 Jun 2017 00:27:33 +0200 +Subject: [PATCH] conf: Pass xmlopt to virDomainSnapshotDefFormat + +This will be used later when a save cookie will become part of the +snapshot XML using new driver specific parser/formatter functions. + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit 957cd268a98043fe061227a8e829c622a6fb4b86) + +https://bugzilla.redhat.com/show_bug.cgi?id=1441662 + +Signed-off-by: Jiri Denemark +--- + src/conf/snapshot_conf.c | 1 + + src/conf/snapshot_conf.h | 1 + + src/esx/esx_driver.c | 2 +- + src/qemu/qemu_domain.c | 4 +++- + src/qemu/qemu_domain.h | 1 + + src/qemu/qemu_driver.c | 16 ++++++++++++---- + src/test/test_driver.c | 1 + + src/vbox/vbox_common.c | 4 ++-- + src/vz/vz_driver.c | 1 + + tests/domainsnapshotxml2xmltest.c | 1 + + 10 files changed, 24 insertions(+), 8 deletions(-) + +diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c +index 7daa9b22ad..e3bba985d7 100644 +--- a/src/conf/snapshot_conf.c ++++ b/src/conf/snapshot_conf.c +@@ -691,6 +691,7 @@ char * + virDomainSnapshotDefFormat(const char *domain_uuid, + virDomainSnapshotDefPtr def, + virCapsPtr caps, ++ virDomainXMLOptionPtr xmlopt ATTRIBUTE_UNUSED, + unsigned int flags, + int internal) + { +diff --git a/src/conf/snapshot_conf.h b/src/conf/snapshot_conf.h +index da904f9460..2ce526fa6b 100644 +--- a/src/conf/snapshot_conf.h ++++ b/src/conf/snapshot_conf.h +@@ -114,6 +114,7 @@ void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def); + char *virDomainSnapshotDefFormat(const char *domain_uuid, + virDomainSnapshotDefPtr def, + virCapsPtr caps, ++ virDomainXMLOptionPtr xmlopt, + unsigned int flags, + int internal); + int virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr snapshot, +diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c +index 166d4bcfcc..c4e1f58a0b 100644 +--- a/src/esx/esx_driver.c ++++ b/src/esx/esx_driver.c +@@ -4282,7 +4282,7 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, + + virUUIDFormat(snapshot->domain->uuid, uuid_string); + +- xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps, ++ xml = virDomainSnapshotDefFormat(uuid_string, &def, priv->caps, priv->xmlopt, + virDomainDefFormatConvertXMLFlags(flags), + 0); + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 11be085801..09903bdd5f 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -4794,6 +4794,7 @@ int + qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, + virDomainSnapshotObjPtr snapshot, + virCapsPtr caps, ++ virDomainXMLOptionPtr xmlopt, + char *snapshotDir) + { + char *newxml = NULL; +@@ -4804,7 +4805,7 @@ qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, + + virUUIDFormat(vm->def->uuid, uuidstr); + newxml = virDomainSnapshotDefFormat( +- uuidstr, snapshot->def, caps, ++ uuidstr, snapshot->def, caps, xmlopt, + virDomainDefFormatConvertXMLFlags(QEMU_DOMAIN_FORMAT_LIVE_FLAGS), + 1); + if (newxml == NULL) +@@ -4965,6 +4966,7 @@ qemuDomainSnapshotDiscard(virQEMUDriverPtr driver, + } else { + parentsnap->def->current = true; + if (qemuDomainSnapshotWriteMetadata(vm, parentsnap, driver->caps, ++ driver->xmlopt, + cfg->snapshotDir) < 0) { + VIR_WARN("failed to set parent snapshot '%s' as current", + snap->def->parent); +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index 2994398a9e..4db92fac8a 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -557,6 +557,7 @@ const char *qemuFindQemuImgBinary(virQEMUDriverPtr driver); + int qemuDomainSnapshotWriteMetadata(virDomainObjPtr vm, + virDomainSnapshotObjPtr snapshot, + virCapsPtr caps, ++ virDomainXMLOptionPtr xmlopt, + char *snapshotDir); + + int qemuDomainSnapshotForEachQcow2(virQEMUDriverPtr driver, +diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c +index 354329fe64..2688c3eec7 100644 +--- a/src/qemu/qemu_driver.c ++++ b/src/qemu/qemu_driver.c +@@ -14650,7 +14650,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, + if (update_current) { + vm->current_snapshot->def->current = false; + if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot, +- driver->caps, ++ driver->caps, driver->xmlopt, + cfg->snapshotDir) < 0) + goto endjob; + vm->current_snapshot = NULL; +@@ -14700,6 +14700,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain, + endjob: + if (snapshot && !(flags & VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA)) { + if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps, ++ driver->xmlopt, + cfg->snapshotDir) < 0) { + /* if writing of metadata fails, error out rather than trying + * to silently carry on without completing the snapshot */ +@@ -15037,7 +15038,8 @@ qemuDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, + + virUUIDFormat(snapshot->domain->uuid, uuidstr); + +- xml = virDomainSnapshotDefFormat(uuidstr, snap->def, driver->caps, ++ xml = virDomainSnapshotDefFormat(uuidstr, snap->def, ++ driver->caps, driver->xmlopt, + virDomainDefFormatConvertXMLFlags(flags), + 0); + +@@ -15219,7 +15221,8 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, + if (vm->current_snapshot) { + vm->current_snapshot->def->current = false; + if (qemuDomainSnapshotWriteMetadata(vm, vm->current_snapshot, +- driver->caps, cfg->snapshotDir) < 0) ++ driver->caps, driver->xmlopt, ++ cfg->snapshotDir) < 0) + goto endjob; + vm->current_snapshot = NULL; + /* XXX Should we restore vm->current_snapshot after this point +@@ -15459,6 +15462,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, + cleanup: + if (ret == 0) { + if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps, ++ driver->xmlopt, + cfg->snapshotDir) < 0) + ret = -1; + else +@@ -15495,6 +15499,7 @@ struct _virQEMUSnapReparent { + virDomainSnapshotObjPtr parent; + virDomainObjPtr vm; + virCapsPtr caps; ++ virDomainXMLOptionPtr xmlopt; + int err; + virDomainSnapshotObjPtr last; + }; +@@ -15523,7 +15528,8 @@ qemuDomainSnapshotReparentChildren(void *payload, + if (!snap->sibling) + rep->last = snap; + +- rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, rep->caps, ++ rep->err = qemuDomainSnapshotWriteMetadata(rep->vm, snap, ++ rep->caps, rep->xmlopt, + rep->cfg->snapshotDir); + return 0; + } +@@ -15594,6 +15600,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { + snap->def->current = true; + if (qemuDomainSnapshotWriteMetadata(vm, snap, driver->caps, ++ driver->xmlopt, + cfg->snapshotDir) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("failed to set snapshot '%s' as current"), +@@ -15611,6 +15618,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot, + rep.err = 0; + rep.last = NULL; + rep.caps = driver->caps; ++ rep.xmlopt = driver->xmlopt; + virDomainSnapshotForEachChild(snap, + qemuDomainSnapshotReparentChildren, + &rep); +diff --git a/src/test/test_driver.c b/src/test/test_driver.c +index 39df646260..c8085dd797 100644 +--- a/src/test/test_driver.c ++++ b/src/test/test_driver.c +@@ -6348,6 +6348,7 @@ testDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, + virUUIDFormat(snapshot->domain->uuid, uuidstr); + + xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->caps, ++ privconn->xmlopt, + virDomainDefFormatConvertXMLFlags(flags), + 0); + +diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c +index dcc64b579c..c739031660 100644 +--- a/src/vbox/vbox_common.c ++++ b/src/vbox/vbox_common.c +@@ -5115,7 +5115,7 @@ vboxSnapshotRedefine(virDomainPtr dom, + VIR_FREE(currentSnapshotXmlFilePath); + if (virAsprintf(¤tSnapshotXmlFilePath, "%s%s.xml", machineLocationPath, snapshotMachineDesc->currentSnapshot) < 0) + goto cleanup; +- char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, VIR_DOMAIN_DEF_FORMAT_SECURE, 0); ++ char *snapshotContent = virDomainSnapshotDefFormat(NULL, def, data->caps, data->xmlopt, VIR_DOMAIN_DEF_FORMAT_SECURE, 0); + if (snapshotContent == NULL) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get snapshot content")); +@@ -6037,7 +6037,7 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, + + virUUIDFormat(dom->uuid, uuidstr); + memcpy(def->dom->uuid, dom->uuid, VIR_UUID_BUFLEN); +- ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps, ++ ret = virDomainSnapshotDefFormat(uuidstr, def, data->caps, data->xmlopt, + virDomainDefFormatConvertXMLFlags(flags), + 0); + +diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c +index 26c4f48459..f0b6722a6e 100644 +--- a/src/vz/vz_driver.c ++++ b/src/vz/vz_driver.c +@@ -2309,6 +2309,7 @@ vzDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned int flags) + virUUIDFormat(snapshot->domain->uuid, uuidstr); + + xml = virDomainSnapshotDefFormat(uuidstr, snap->def, privconn->driver->caps, ++ privconn->driver->xmlopt, + virDomainDefFormatConvertXMLFlags(flags), + 0); + +diff --git a/tests/domainsnapshotxml2xmltest.c b/tests/domainsnapshotxml2xmltest.c +index f5fec47520..df204f9f16 100644 +--- a/tests/domainsnapshotxml2xmltest.c ++++ b/tests/domainsnapshotxml2xmltest.c +@@ -101,6 +101,7 @@ testCompareXMLToXMLFiles(const char *inxml, + goto cleanup; + + if (!(actual = virDomainSnapshotDefFormat(uuid, def, driver.caps, ++ driver.xmlopt, + VIR_DOMAIN_DEF_FORMAT_SECURE, + internal))) + goto cleanup; +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-Provide-error-on-undefined-iothreadsched-entry.patch b/SOURCES/libvirt-conf-Provide-error-on-undefined-iothreadsched-entry.patch deleted file mode 100644 index 9ab1464..0000000 --- a/SOURCES/libvirt-conf-Provide-error-on-undefined-iothreadsched-entry.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 1a6ed7e15d95b976797a30f1f8b76817765c6e64 Mon Sep 17 00:00:00 2001 -Message-Id: <1a6ed7e15d95b976797a30f1f8b76817765c6e64@dist-git> -From: John Ferlan -Date: Tue, 16 Aug 2016 11:43:52 -0400 -Subject: [PATCH] conf: Provide error on undefined iothreadsched entry - -https://bugzilla.redhat.com/show_bug.cgi?id=1366484 - -When commit id '6dfb4507' refactored where the iothreadsched data was -stored, the error message for when the virDomainIOThreadIDFind failed -to find an iothreadid ("iothreadsched attribute 'iothreads' uses -undefined iothread ids") was lost. This led to the possibility that -someone would try to use it, but receive the generic message "An error -occurred, but the cause is unknown". - -This patch adds the error message back so that someone will know that -they have an invalid configuration. - -Signed-off-by: John Ferlan -(cherry picked from commit 8c6b29e7b41d678ab9c5542efd607b28776e4f24) ---- - src/conf/domain_conf.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 33954f7..ffafef3 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -15532,8 +15532,12 @@ virDomainDefGetIOThreadSched(virDomainDefPtr def, - { - virDomainIOThreadIDDefPtr iothrinfo; - -- if (!(iothrinfo = virDomainIOThreadIDFind(def, iothread))) -+ if (!(iothrinfo = virDomainIOThreadIDFind(def, iothread))) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("Cannot find 'iothread' : %u"), -+ iothread); - return NULL; -+ } - - return &iothrinfo->sched; - } --- -2.9.2 - diff --git a/SOURCES/libvirt-conf-Provide-error-on-undefined-vcpusched-entry.patch b/SOURCES/libvirt-conf-Provide-error-on-undefined-vcpusched-entry.patch deleted file mode 100644 index e6e7493..0000000 --- a/SOURCES/libvirt-conf-Provide-error-on-undefined-vcpusched-entry.patch +++ /dev/null @@ -1,40 +0,0 @@ -From 6c04a4844d053c51238b5b1c47df95b0d6cba677 Mon Sep 17 00:00:00 2001 -Message-Id: <6c04a4844d053c51238b5b1c47df95b0d6cba677@dist-git> -From: John Ferlan -Date: Wed, 24 Aug 2016 16:11:16 -0400 -Subject: [PATCH] conf: Provide error on undefined vcpusched entry - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Modify virDomainDefGetVcpuSched to emit an error message if -virDomainDefGetVcpu returns NULL meaning the vcpu could not -be found. Prior to commit id '9cc931f0b' the error message -would have been issued in virDomainDefGetVcpu. - -(cherry picked from commit 4b15fd0d1f3b63c0feb847b1bfe93cee46813601) ---- - src/conf/domain_conf.c | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 8e5afe7..4e703d9 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -1477,8 +1477,12 @@ virDomainDefGetVcpuSched(virDomainDefPtr def, - { - virDomainVcpuDefPtr vcpuinfo; - -- if (!(vcpuinfo = virDomainDefGetVcpu(def, vcpu))) -+ if (!(vcpuinfo = virDomainDefGetVcpu(def, vcpu))) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("vCPU '%u' is not present in domain definition"), -+ vcpu); - return NULL; -+ } - - return &vcpuinfo->sched; - } --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Refactor-virCPUDefParseXML.patch b/SOURCES/libvirt-conf-Refactor-virCPUDefParseXML.patch new file mode 100644 index 0000000..eaa2ab7 --- /dev/null +++ b/SOURCES/libvirt-conf-Refactor-virCPUDefParseXML.patch @@ -0,0 +1,413 @@ +From 7bdac52dd6979f76f9a75a404a76e79f7da11a06 Mon Sep 17 00:00:00 2001 +Message-Id: <7bdac52dd6979f76f9a75a404a76e79f7da11a06@dist-git> +From: Jiri Denemark +Date: Tue, 23 May 2017 09:29:36 +0200 +Subject: [PATCH] conf: Refactor virCPUDefParseXML + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit 702013f3b3ad8bd28c326058e2dd9ea8afbd1e61) + +https://bugzilla.redhat.com/show_bug.cgi?id=1441662 + +Signed-off-by: Jiri Denemark +--- + src/conf/cpu_conf.c | 109 +++++++++++++++++++++++++++---------------------- + src/conf/cpu_conf.h | 9 ++-- + src/conf/domain_conf.c | 12 +----- + src/cpu/cpu.c | 5 +-- + tests/cputest.c | 5 +-- + 5 files changed, 72 insertions(+), 68 deletions(-) + +diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c +index ffb2e83d67..da40e9ba97 100644 +--- a/src/conf/cpu_conf.c ++++ b/src/conf/cpu_conf.c +@@ -245,12 +245,25 @@ virCPUDefCopy(const virCPUDef *cpu) + } + + +-virCPUDefPtr +-virCPUDefParseXML(xmlNodePtr node, +- xmlXPathContextPtr ctxt, +- virCPUType type) ++/* ++ * Parses CPU definition XML from a node pointed to by @xpath. If @xpath is ++ * NULL, the current node of @ctxt is used (i.e., it is a shortcut to "."). ++ * ++ * Missing element in the XML document is not considered an error unless ++ * @xpath is NULL in which case the function expects it was provided with a ++ * valid element already. In other words, the function returns success ++ * and sets @cpu to NULL if @xpath is not NULL and the node pointed to by ++ * @xpath is not found. ++ * ++ * Returns 0 on success, -1 on error. ++ */ ++int ++virCPUDefParseXML(xmlXPathContextPtr ctxt, ++ const char *xpath, ++ virCPUType type, ++ virCPUDefPtr *cpu) + { +- virCPUDefPtr def; ++ virCPUDefPtr def = NULL; + xmlNodePtr *nodes = NULL; + xmlNodePtr oldnode = ctxt->node; + int n; +@@ -258,15 +271,23 @@ virCPUDefParseXML(xmlNodePtr node, + char *cpuMode; + char *fallback = NULL; + char *vendor_id = NULL; ++ int ret = -1; + +- if (!xmlStrEqual(node->name, BAD_CAST "cpu")) { ++ *cpu = NULL; ++ ++ if (xpath && !(ctxt->node = virXPathNode(xpath, ctxt))) { ++ ret = 0; ++ goto cleanup; ++ } ++ ++ if (!xmlStrEqual(ctxt->node->name, BAD_CAST "cpu")) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("XML does not contain expected 'cpu' element")); +- return NULL; ++ goto cleanup; + } + + if (VIR_ALLOC(def) < 0) +- return NULL; ++ goto cleanup; + + if (type == VIR_CPU_TYPE_AUTO) { + if (virXPathBoolean("boolean(./arch)", ctxt)) { +@@ -274,7 +295,7 @@ virCPUDefParseXML(xmlNodePtr node, + virReportError(VIR_ERR_XML_ERROR, "%s", + _("'arch' element cannot be used inside 'cpu'" + " element with 'match' attribute'")); +- goto error; ++ goto cleanup; + } + def->type = VIR_CPU_TYPE_HOST; + } else { +@@ -284,12 +305,12 @@ virCPUDefParseXML(xmlNodePtr node, + def->type = type; + } + +- if ((cpuMode = virXMLPropString(node, "mode"))) { ++ if ((cpuMode = virXMLPropString(ctxt->node, "mode"))) { + if (def->type == VIR_CPU_TYPE_HOST) { + VIR_FREE(cpuMode); + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Attribute mode is only allowed for guest CPU")); +- goto error; ++ goto cleanup; + } else { + def->mode = virCPUModeTypeFromString(cpuMode); + +@@ -298,7 +319,7 @@ virCPUDefParseXML(xmlNodePtr node, + _("Invalid mode attribute '%s'"), + cpuMode); + VIR_FREE(cpuMode); +- goto error; ++ goto cleanup; + } + VIR_FREE(cpuMode); + } +@@ -310,7 +331,7 @@ virCPUDefParseXML(xmlNodePtr node, + } + + if (def->type == VIR_CPU_TYPE_GUEST) { +- char *match = virXMLPropString(node, "match"); ++ char *match = virXMLPropString(ctxt->node, "match"); + char *check; + + if (!match) { +@@ -326,11 +347,11 @@ virCPUDefParseXML(xmlNodePtr node, + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid match attribute for CPU " + "specification")); +- goto error; ++ goto cleanup; + } + } + +- if ((check = virXMLPropString(node, "check"))) { ++ if ((check = virXMLPropString(ctxt->node, "check"))) { + int value = virCPUCheckTypeFromString(check); + VIR_FREE(check); + +@@ -338,7 +359,7 @@ virCPUDefParseXML(xmlNodePtr node, + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid check attribute for CPU " + "specification")); +- goto error; ++ goto cleanup; + } + def->check = value; + } +@@ -349,13 +370,13 @@ virCPUDefParseXML(xmlNodePtr node, + if (!arch) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing CPU architecture")); +- goto error; ++ goto cleanup; + } + if ((def->arch = virArchFromString(arch)) == VIR_ARCH_NONE) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unknown architecture %s"), arch); + VIR_FREE(arch); +- goto error; ++ goto cleanup; + } + VIR_FREE(arch); + } +@@ -364,7 +385,7 @@ virCPUDefParseXML(xmlNodePtr node, + def->type == VIR_CPU_TYPE_HOST) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing CPU model name")); +- goto error; ++ goto cleanup; + } + + if (def->type == VIR_CPU_TYPE_GUEST && +@@ -374,7 +395,7 @@ virCPUDefParseXML(xmlNodePtr node, + if ((def->fallback = virCPUFallbackTypeFromString(fallback)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid fallback attribute")); +- goto error; ++ goto cleanup; + } + } + +@@ -384,14 +405,14 @@ virCPUDefParseXML(xmlNodePtr node, + virReportError(VIR_ERR_XML_ERROR, + _("vendor_id must be exactly %d characters long"), + VIR_CPU_VENDOR_ID_LENGTH); +- goto error; ++ goto cleanup; + } + + /* ensure that the string can be passed to qemu*/ + if (strchr(vendor_id, ',')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("vendor id is invalid")); +- goto error; ++ goto cleanup; + } + + def->vendor_id = vendor_id; +@@ -403,61 +424,54 @@ virCPUDefParseXML(xmlNodePtr node, + if (def->vendor && !def->model) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("CPU vendor specified without CPU model")); +- goto error; ++ goto cleanup; + } + + if (virXPathNode("./topology[1]", ctxt)) { +- int ret; + unsigned long ul; + +- ret = virXPathULong("string(./topology[1]/@sockets)", +- ctxt, &ul); +- if (ret < 0) { ++ if (virXPathULong("string(./topology[1]/@sockets)", ctxt, &ul) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'sockets' attribute in CPU topology")); +- goto error; ++ goto cleanup; + } + def->sockets = (unsigned int) ul; + +- ret = virXPathULong("string(./topology[1]/@cores)", +- ctxt, &ul); +- if (ret < 0) { ++ if (virXPathULong("string(./topology[1]/@cores)", ctxt, &ul) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'cores' attribute in CPU topology")); +- goto error; ++ goto cleanup; + } + def->cores = (unsigned int) ul; + +- ret = virXPathULong("string(./topology[1]/@threads)", +- ctxt, &ul); +- if (ret < 0) { ++ if (virXPathULong("string(./topology[1]/@threads)", ctxt, &ul) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing 'threads' attribute in CPU topology")); +- goto error; ++ goto cleanup; + } + def->threads = (unsigned int) ul; + + if (!def->sockets || !def->cores || !def->threads) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid CPU topology")); +- goto error; ++ goto cleanup; + } + } + + if ((n = virXPathNodeSet("./feature", ctxt, &nodes)) < 0) +- goto error; ++ goto cleanup; + + if (n > 0) { + if (!def->model && def->mode == VIR_CPU_MODE_CUSTOM) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Non-empty feature list specified without " + "CPU model")); +- goto error; ++ goto cleanup; + } + + if (VIR_RESIZE_N(def->features, def->nfeatures_max, + def->nfeatures, n) < 0) +- goto error; ++ goto cleanup; + + def->nfeatures = n; + } +@@ -480,7 +494,7 @@ virCPUDefParseXML(xmlNodePtr node, + if (policy < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Invalid CPU feature policy")); +- goto error; ++ goto cleanup; + } + } else { + policy = -1; +@@ -490,7 +504,7 @@ virCPUDefParseXML(xmlNodePtr node, + VIR_FREE(name); + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Invalid CPU feature name")); +- goto error; ++ goto cleanup; + } + + for (j = 0; j < i; j++) { +@@ -499,7 +513,7 @@ virCPUDefParseXML(xmlNodePtr node, + _("CPU feature '%s' specified more than once"), + name); + VIR_FREE(name); +- goto error; ++ goto cleanup; + } + } + +@@ -542,17 +556,16 @@ virCPUDefParseXML(xmlNodePtr node, + def->cache->mode = mode; + } + ++ VIR_STEAL_PTR(*cpu, def); ++ ret = 0; ++ + cleanup: + ctxt->node = oldnode; + VIR_FREE(fallback); + VIR_FREE(vendor_id); + VIR_FREE(nodes); +- return def; +- +- error: + virCPUDefFree(def); +- def = NULL; +- goto cleanup; ++ return ret; + } + + +diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h +index b0d891552a..b44974f47e 100644 +--- a/src/conf/cpu_conf.h ++++ b/src/conf/cpu_conf.h +@@ -182,10 +182,11 @@ virCPUDefCopy(const virCPUDef *cpu); + virCPUDefPtr + virCPUDefCopyWithoutModel(const virCPUDef *cpu); + +-virCPUDefPtr +-virCPUDefParseXML(xmlNodePtr node, +- xmlXPathContextPtr ctxt, +- virCPUType mode); ++int ++virCPUDefParseXML(xmlXPathContextPtr ctxt, ++ const char *xpath, ++ virCPUType mode, ++ virCPUDefPtr *cpu); + + bool + virCPUDefIsEqual(virCPUDefPtr src, +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 2197330a22..395dcc0531 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -17418,16 +17418,8 @@ virDomainDefParseXML(xmlDocPtr xml, + } + VIR_FREE(nodes); + +- /* analysis of cpu handling */ +- if ((node = virXPathNode("./cpu[1]", ctxt)) != NULL) { +- xmlNodePtr oldnode = ctxt->node; +- ctxt->node = node; +- def->cpu = virCPUDefParseXML(node, ctxt, VIR_CPU_TYPE_GUEST); +- ctxt->node = oldnode; +- +- if (def->cpu == NULL) +- goto error; +- } ++ if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu) < 0) ++ goto error; + + if (virDomainNumaDefCPUParseXML(def->numa, ctxt) < 0) + goto error; +diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c +index 702b14dbb7..96160901e1 100644 +--- a/src/cpu/cpu.c ++++ b/src/cpu/cpu.c +@@ -130,7 +130,7 @@ virCPUCompareXML(virArch arch, + if (!(doc = virXMLParseStringCtxt(xml, _("(CPU_definition)"), &ctxt))) + goto cleanup; + +- if (!(cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO))) ++ if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu) < 0) + goto cleanup; + + ret = virCPUCompare(arch, host, cpu, failIncompatible); +@@ -562,8 +562,7 @@ cpuBaselineXML(const char **xmlCPUs, + if (!(doc = virXMLParseStringCtxt(xmlCPUs[i], _("(CPU_definition)"), &ctxt))) + goto error; + +- cpus[i] = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_HOST); +- if (cpus[i] == NULL) ++ if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0) + goto error; + + xmlXPathFreeContext(ctxt); +diff --git a/tests/cputest.c b/tests/cputest.c +index efa891dc18..97b34de9ed 100644 +--- a/tests/cputest.c ++++ b/tests/cputest.c +@@ -88,7 +88,7 @@ cpuTestLoadXML(virArch arch, const char *name) + if (!(doc = virXMLParseFileCtxt(xml, &ctxt))) + goto cleanup; + +- cpu = virCPUDefParseXML(ctxt->node, ctxt, VIR_CPU_TYPE_AUTO); ++ virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_AUTO, &cpu); + + cleanup: + xmlXPathFreeContext(ctxt); +@@ -126,8 +126,7 @@ cpuTestLoadMultiXML(virArch arch, + + for (i = 0; i < n; i++) { + ctxt->node = nodes[i]; +- cpus[i] = virCPUDefParseXML(nodes[i], ctxt, VIR_CPU_TYPE_HOST); +- if (!cpus[i]) ++ if (virCPUDefParseXML(ctxt, NULL, VIR_CPU_TYPE_HOST, &cpus[i]) < 0) + goto cleanup_cpus; + } + +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-Remove-incorrect-check-when-encoding-shmem-audit-message.patch b/SOURCES/libvirt-conf-Remove-incorrect-check-when-encoding-shmem-audit-message.patch deleted file mode 100644 index fd65de2..0000000 --- a/SOURCES/libvirt-conf-Remove-incorrect-check-when-encoding-shmem-audit-message.patch +++ /dev/null @@ -1,44 +0,0 @@ -From 5005542c10ebdf6fcb4d76f31c522cc1c9136a67 Mon Sep 17 00:00:00 2001 -Message-Id: <5005542c10ebdf6fcb4d76f31c522cc1c9136a67@dist-git> -From: John Ferlan -Date: Fri, 4 Nov 2016 10:29:45 +0100 -Subject: [PATCH] conf: Remove incorrect check when encoding shmem audit - message - -Remove the !size check since size is initialized to NULL and thus -causing the condition to always be true - -(cherry picked from commit c951cdbff94ff577c5caa3dfff4153a161c073e6) - -https://bugzilla.redhat.com/show_bug.cgi?id=1389013 - -Signed-off-by: Martin Kletzander ---- - src/conf/domain_audit.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c -index f0cc49c..be962d6 100644 ---- a/src/conf/domain_audit.c -+++ b/src/conf/domain_audit.c -@@ -982,7 +982,7 @@ virDomainAuditShmem(virDomainObjPtr vm, - - virUUIDFormat(vm->def->uuid, uuidstr); - -- if (!vmname || !src || !size || !shmem || -+ if (!vmname || !src || !shmem || - virAsprintfQuiet(&size, "%llu", def->size) < 0) { - VIR_WARN("OOM while encoding audit message"); - goto cleanup; -@@ -996,7 +996,7 @@ virDomainAuditShmem(virDomainObjPtr vm, - - VIR_AUDIT(VIR_AUDIT_RECORD_RESOURCE, success, - "virt=%s resrc=shmem reason=%s %s uuid=%s size=%s %s %s", -- virt, reason, vmname, uuidstr, size ?: "?", shmem, src); -+ virt, reason, vmname, uuidstr, size, shmem, src); - - cleanup: - VIR_FREE(vmname); --- -2.10.2 - diff --git a/SOURCES/libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch b/SOURCES/libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch index 7fde20c..1c46aaf 100644 --- a/SOURCES/libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch +++ b/SOURCES/libvirt-conf-Rename-mode-parameter-in-virCPUDefParseXML.patch @@ -1,5 +1,5 @@ -From 199cd8f7c434fb1248ba3338bd9e402ffe7bc57b Mon Sep 17 00:00:00 2001 -Message-Id: <199cd8f7c434fb1248ba3338bd9e402ffe7bc57b@dist-git> +From 46761b7fdb0707036482c98eb3a80279753df484 Mon Sep 17 00:00:00 2001 +Message-Id: <46761b7fdb0707036482c98eb3a80279753df484@dist-git> From: Jiri Denemark Date: Mon, 24 Apr 2017 15:38:41 +0200 Subject: [PATCH] conf: Rename mode parameter in virCPUDefParseXML @@ -10,7 +10,7 @@ strange, 'type' is a much better name. Signed-off-by: Jiri Denemark (cherry picked from commit e841a41169dd726af13f29cb57fbafe658b7011a) -https://bugzilla.redhat.com/show_bug.cgi?id=1447612 +https://bugzilla.redhat.com/show_bug.cgi?id=1428952 Signed-off-by: Jiri Denemark --- @@ -18,10 +18,10 @@ Signed-off-by: Jiri Denemark 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c -index b71528ef5..9ffaf1e95 100644 +index b78531e60..623b1699f 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c -@@ -144,7 +144,7 @@ virCPUDefCopy(const virCPUDef *cpu) +@@ -230,7 +230,7 @@ virCPUDefCopy(const virCPUDef *cpu) virCPUDefPtr virCPUDefParseXML(xmlNodePtr node, xmlXPathContextPtr ctxt, @@ -30,7 +30,7 @@ index b71528ef5..9ffaf1e95 100644 { virCPUDefPtr def; xmlNodePtr *nodes = NULL; -@@ -164,7 +164,7 @@ virCPUDefParseXML(xmlNodePtr node, +@@ -250,7 +250,7 @@ virCPUDefParseXML(xmlNodePtr node, if (VIR_ALLOC(def) < 0) return NULL; @@ -39,7 +39,7 @@ index b71528ef5..9ffaf1e95 100644 if (virXPathBoolean("boolean(./arch)", ctxt)) { if (virXPathBoolean("boolean(./@match)", ctxt)) { virReportError(VIR_ERR_XML_ERROR, "%s", -@@ -177,7 +177,7 @@ virCPUDefParseXML(xmlNodePtr node, +@@ -263,7 +263,7 @@ virCPUDefParseXML(xmlNodePtr node, def->type = VIR_CPU_TYPE_GUEST; } } else { diff --git a/SOURCES/libvirt-conf-Rename-virDomainVcpuInfoPtr-to-virDomainVcpuDefPtr.patch b/SOURCES/libvirt-conf-Rename-virDomainVcpuInfoPtr-to-virDomainVcpuDefPtr.patch deleted file mode 100644 index ae4b8cf..0000000 --- a/SOURCES/libvirt-conf-Rename-virDomainVcpuInfoPtr-to-virDomainVcpuDefPtr.patch +++ /dev/null @@ -1,320 +0,0 @@ -From 847361f1eeda21c6dd8dcf73821b4ecf341095b1 Mon Sep 17 00:00:00 2001 -Message-Id: <847361f1eeda21c6dd8dcf73821b4ecf341095b1@dist-git> -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:10:44 -0400 -Subject: [PATCH] conf: Rename virDomainVcpuInfoPtr to virDomainVcpuDefPtr - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -(cherry picked from commit c7d5dd3974df1edb6a1cd8fce989eea43d72527f) ---- - src/conf/domain_conf.c | 22 +++++++++++----------- - src/conf/domain_conf.h | 10 +++++----- - src/libxl/libxl_domain.c | 2 +- - src/libxl/libxl_driver.c | 2 +- - src/qemu/qemu_cgroup.c | 2 +- - src/qemu/qemu_driver.c | 14 +++++++------- - src/qemu/qemu_process.c | 4 ++-- - src/test/test_driver.c | 4 ++-- - src/vz/vz_sdk.c | 2 +- - 9 files changed, 31 insertions(+), 31 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 9571ee3..a923b60 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -1313,7 +1313,7 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def) - - - static void --virDomainVcpuInfoClear(virDomainVcpuInfoPtr info) -+virDomainVcpuDefClear(virDomainVcpuDefPtr info) - { - if (!info) - return; -@@ -1337,7 +1337,7 @@ virDomainDefSetVcpusMax(virDomainDefPtr def, - return -1; - } else { - for (i = maxvcpus; i < def->maxvcpus; i++) -- virDomainVcpuInfoClear(&def->vcpus[i]); -+ virDomainVcpuDefClear(&def->vcpus[i]); - - VIR_SHRINK_N(def->vcpus, def->maxvcpus, def->maxvcpus - maxvcpus); - } -@@ -1429,7 +1429,7 @@ virDomainDefGetOnlineVcpumap(const virDomainDef *def) - } - - --virDomainVcpuInfoPtr -+virDomainVcpuDefPtr - virDomainDefGetVcpu(virDomainDefPtr def, - unsigned int vcpu) - { -@@ -1448,7 +1448,7 @@ static virDomainThreadSchedParamPtr - virDomainDefGetVcpuSched(virDomainDefPtr def, - unsigned int vcpu) - { -- virDomainVcpuInfoPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo; - - if (!(vcpuinfo = virDomainDefGetVcpu(def, vcpu))) - return NULL; -@@ -1514,7 +1514,7 @@ virDomainDefGetVcpuPinInfoHelper(virDomainDefPtr def, - virBitmapSetAll(allcpumap); - - for (i = 0; i < maxvcpus && i < ncpumaps; i++) { -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(def, i); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i); - virBitmapPtr bitmap = NULL; - - if (vcpu->cpumask) -@@ -2530,7 +2530,7 @@ void virDomainDefFree(virDomainDefPtr def) - virDomainResourceDefFree(def->resource); - - for (i = 0; i < def->maxvcpus; i++) -- virDomainVcpuInfoClear(&def->vcpus[i]); -+ virDomainVcpuDefClear(&def->vcpus[i]); - VIR_FREE(def->vcpus); - - /* hostdevs must be freed before nets (or any future "intelligent -@@ -4270,7 +4270,7 @@ static void - virDomainDefRemoveOfflineVcpuPin(virDomainDefPtr def) - { - size_t i; -- virDomainVcpuInfoPtr vcpu; -+ virDomainVcpuDefPtr vcpu; - - for (i = 0; i < virDomainDefGetVcpusMax(def); i++) { - vcpu = virDomainDefGetVcpu(def, i); -@@ -14975,7 +14975,7 @@ static int - virDomainVcpuPinDefParseXML(virDomainDefPtr def, - xmlNodePtr node) - { -- virDomainVcpuInfoPtr vcpu; -+ virDomainVcpuDefPtr vcpu; - unsigned int vcpuid; - char *tmp = NULL; - int ret = -1; -@@ -18638,8 +18638,8 @@ virDomainDefVcpuCheckAbiStability(virDomainDefPtr src, - } - - for (i = 0; i < src->maxvcpus; i++) { -- virDomainVcpuInfoPtr svcpu = &src->vcpus[i]; -- virDomainVcpuInfoPtr dvcpu = &dst->vcpus[i]; -+ virDomainVcpuDefPtr svcpu = &src->vcpus[i]; -+ virDomainVcpuDefPtr dvcpu = &dst->vcpus[i]; - - if (svcpu->online != dvcpu->online) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -@@ -22823,7 +22823,7 @@ virDomainCputuneDefFormat(virBufferPtr buf, - - for (i = 0; i < def->maxvcpus; i++) { - char *cpumask; -- virDomainVcpuInfoPtr vcpu = def->vcpus + i; -+ virDomainVcpuDefPtr vcpu = def->vcpus + i; - - if (!vcpu->cpumask) - continue; -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 6eed30e..c20ea79 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2035,10 +2035,10 @@ struct _virDomainCputune { - }; - - --typedef struct _virDomainVcpuInfo virDomainVcpuInfo; --typedef virDomainVcpuInfo *virDomainVcpuInfoPtr; -+typedef struct _virDomainVcpuDef virDomainVcpuDef; -+typedef virDomainVcpuDef *virDomainVcpuDefPtr; - --struct _virDomainVcpuInfo { -+struct _virDomainVcpuDef { - bool online; - virBitmapPtr cpumask; - -@@ -2132,7 +2132,7 @@ struct _virDomainDef { - virDomainBlkiotune blkio; - virDomainMemtune mem; - -- virDomainVcpuInfoPtr vcpus; -+ virDomainVcpuDefPtr vcpus; - size_t maxvcpus; - int placement_mode; - virBitmapPtr cpumask; -@@ -2267,7 +2267,7 @@ unsigned int virDomainDefGetVcpusMax(const virDomainDef *def); - int virDomainDefSetVcpus(virDomainDefPtr def, unsigned int vcpus); - unsigned int virDomainDefGetVcpus(const virDomainDef *def); - virBitmapPtr virDomainDefGetOnlineVcpumap(const virDomainDef *def); --virDomainVcpuInfoPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu) -+virDomainVcpuDefPtr virDomainDefGetVcpu(virDomainDefPtr def, unsigned int vcpu) - ATTRIBUTE_RETURN_CHECK; - - unsigned long long virDomainDefGetMemoryInitial(const virDomainDef *def); -diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c -index 9feba08..0e26b91 100644 ---- a/src/libxl/libxl_domain.c -+++ b/src/libxl/libxl_domain.c -@@ -841,7 +841,7 @@ int - libxlDomainSetVcpuAffinities(libxlDriverPrivatePtr driver, virDomainObjPtr vm) - { - libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); -- virDomainVcpuInfoPtr vcpu; -+ virDomainVcpuDefPtr vcpu; - libxl_bitmap map; - virBitmapPtr cpumask = NULL; - size_t i; -diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c -index 3189f1c..be6017a 100644 ---- a/src/libxl/libxl_driver.c -+++ b/src/libxl/libxl_driver.c -@@ -2284,7 +2284,7 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu, - libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver); - virDomainDefPtr targetDef = NULL; - virBitmapPtr pcpumap = NULL; -- virDomainVcpuInfoPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo; - virDomainObjPtr vm; - int ret = -1; - -diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c -index 1e04a68..2dca874 100644 ---- a/src/qemu/qemu_cgroup.c -+++ b/src/qemu/qemu_cgroup.c -@@ -874,7 +874,7 @@ qemuRestoreCgroupState(virDomainObjPtr vm) - goto error; - - for (i = 0; i < virDomainDefGetVcpusMax(vm->def); i++) { -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(vm->def, i); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i); - - if (!vcpu->online) - continue; -diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index 9c6c1cf..b4ab095 100644 ---- a/src/qemu/qemu_driver.c -+++ b/src/qemu/qemu_driver.c -@@ -1475,7 +1475,7 @@ qemuDomainHelperGetVcpus(virDomainObjPtr vm, - memset(cpumaps, 0, sizeof(*cpumaps) * maxinfo); - - for (i = 0; i < virDomainDefGetVcpusMax(vm->def) && ncpuinfo < maxinfo; i++) { -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(vm->def, i); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i); - pid_t vcpupid = qemuDomainGetVcpuPid(vm, i); - - if (!vcpu->online) -@@ -4620,7 +4620,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriverPtr driver, - unsigned int vcpu) - { - qemuDomainObjPrivatePtr priv = vm->privateData; -- virDomainVcpuInfoPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo; - int ret = -1; - int rc; - int oldvcpus = virDomainDefGetVcpus(vm->def); -@@ -4672,7 +4672,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, - unsigned int vcpu) - { - qemuDomainObjPrivatePtr priv = vm->privateData; -- virDomainVcpuInfoPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo; - int ret = -1; - int rc; - int oldvcpus = virDomainDefGetVcpus(vm->def); -@@ -4919,7 +4919,7 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm, - virBitmapPtr cpumap) - { - virBitmapPtr tmpmap = NULL; -- virDomainVcpuInfoPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo; - qemuDomainObjPrivatePtr priv = vm->privateData; - virCgroupPtr cgroup_vcpu = NULL; - char *str = NULL; -@@ -5006,7 +5006,7 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, - virDomainDefPtr persistentDef; - int ret = -1; - virBitmapPtr pcpumap = NULL; -- virDomainVcpuInfoPtr vcpuinfo = NULL; -+ virDomainVcpuDefPtr vcpuinfo = NULL; - virQEMUDriverConfigPtr cfg = NULL; - - virCheckFlags(VIR_DOMAIN_AFFECT_LIVE | -@@ -9365,7 +9365,7 @@ qemuDomainSetNumaParamsLive(virDomainObjPtr vm, - virCgroupFree(&cgroup_temp); - - for (i = 0; i < virDomainDefGetVcpusMax(vm->def); i++) { -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(vm->def, i); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i); - - if (!vcpu->online) - continue; -@@ -9776,7 +9776,7 @@ qemuSetVcpusBWLive(virDomainObjPtr vm, virCgroupPtr cgroup, - return 0; - - for (i = 0; i < virDomainDefGetVcpusMax(vm->def); i++) { -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(vm->def, i); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, i); - - if (!vcpu->online) - continue; -diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c -index 2f0ef2b..6062f2a 100644 ---- a/src/qemu/qemu_process.c -+++ b/src/qemu/qemu_process.c -@@ -4577,7 +4577,7 @@ qemuProcessSetupVcpu(virDomainObjPtr vm, - unsigned int vcpuid) - { - pid_t vcpupid = qemuDomainGetVcpuPid(vm, vcpuid); -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(vm->def, vcpuid); - qemuDomainObjPrivatePtr priv = vm->privateData; - char *mem_mask = NULL; - virDomainNumatuneMemMode mem_mode; -@@ -4658,7 +4658,7 @@ qemuProcessSetupVcpu(virDomainObjPtr vm, - static int - qemuProcessSetupVcpus(virDomainObjPtr vm) - { -- virDomainVcpuInfoPtr vcpu; -+ virDomainVcpuDefPtr vcpu; - unsigned int maxvcpus = virDomainDefGetVcpusMax(vm->def); - size_t i; - -diff --git a/src/test/test_driver.c b/src/test/test_driver.c -index baff085..e7bca81 100644 ---- a/src/test/test_driver.c -+++ b/src/test/test_driver.c -@@ -2457,7 +2457,7 @@ static int testDomainGetVcpus(virDomainPtr domain, - memset(cpumaps, 0, maxinfo * maplen); - - for (i = 0; i < maxinfo; i++) { -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(def, i); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i); - virBitmapPtr bitmap = NULL; - - if (!vcpu->online) -@@ -2493,7 +2493,7 @@ static int testDomainPinVcpu(virDomainPtr domain, - unsigned char *cpumap, - int maplen) - { -- virDomainVcpuInfoPtr vcpuinfo; -+ virDomainVcpuDefPtr vcpuinfo; - virDomainObjPtr privdom; - virDomainDefPtr def; - int ret = -1; -diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c -index ae218e9..9d0bc0d 100644 ---- a/src/vz/vz_sdk.c -+++ b/src/vz/vz_sdk.c -@@ -2284,7 +2284,7 @@ prlsdkCheckUnsupportedParams(PRL_HANDLE sdkdom, virDomainDefPtr def) - } - - for (i = 0; i < virDomainDefGetVcpusMax(def); i++) { -- virDomainVcpuInfoPtr vcpu = virDomainDefGetVcpu(def, i); -+ virDomainVcpuDefPtr vcpu = virDomainDefGetVcpu(def, i); - - if (vcpu->cpumask && - !virBitmapEqual(def->cpumask, vcpu->cpumask)) { --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-Resolve-corner-case-on-fc_host-deletion.patch b/SOURCES/libvirt-conf-Resolve-corner-case-on-fc_host-deletion.patch new file mode 100644 index 0000000..b5bfc3e --- /dev/null +++ b/SOURCES/libvirt-conf-Resolve-corner-case-on-fc_host-deletion.patch @@ -0,0 +1,59 @@ +From 70c60798f09324a9e4d91f787cad493a1ceca5d9 Mon Sep 17 00:00:00 2001 +Message-Id: <70c60798f09324a9e4d91f787cad493a1ceca5d9@dist-git> +From: John Ferlan +Date: Wed, 24 May 2017 10:27:57 -0400 +Subject: [PATCH] conf: Resolve corner case on fc_host deletion + +https://bugzilla.redhat.com/show_bug.cgi?id=1420740 + +Testing found an inventive way to cause an error at shutdown by providing the +parent name for the fc host creation using the "same name" as the HBA. Since +the code thus assumed the parent host name provided was the parent HBA and +just extracted out the host number and sent that along to the vport_destroy +this avoided checks made for equality. + +So just add the equality check to that path to resolve. + +(cherry picked from commit 2c8e30ee7e287d6490f643ccd2d7653a834e75e5) +Signed-off-by: John Ferlan +Signed-off-by: Jiri Denemark +--- + src/conf/node_device_conf.c | 14 +++++++++++--- + 1 file changed, 11 insertions(+), 3 deletions(-) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index ac61db34c..2d0b14850 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -2300,17 +2300,25 @@ virNodeDeviceDeleteVport(virConnectPtr conn, + goto cleanup; + } + ++ if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) ++ goto cleanup; ++ + /* If at startup time we provided a parent, then use that to + * get the parent_host value; otherwise, we have to determine + * the parent scsi_host which we did not save at startup time + */ + if (fchost->parent) { ++ /* Someone provided a parent string at startup time that ++ * was the same as the scsi_host - meaning we have a pool ++ * backed to an HBA, so there won't be a vHBA to delete */ ++ if (STREQ(scsi_host_name, fchost->parent)) { ++ ret = 0; ++ goto cleanup; ++ } ++ + if (virSCSIHostGetNumber(fchost->parent, &parent_host) < 0) + goto cleanup; + } else { +- if (virAsprintf(&scsi_host_name, "scsi_%s", name) < 0) +- goto cleanup; +- + if (!(vhba_parent = virNodeDeviceGetParentName(conn, scsi_host_name))) + goto cleanup; + +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-add-ABI-stability-checks-for-IOMMU-options.patch b/SOURCES/libvirt-conf-add-ABI-stability-checks-for-IOMMU-options.patch new file mode 100644 index 0000000..c3c59ef --- /dev/null +++ b/SOURCES/libvirt-conf-add-ABI-stability-checks-for-IOMMU-options.patch @@ -0,0 +1,64 @@ +From 4383e358e2d8a85bd46936c997071c3b776fffd0 Mon Sep 17 00:00:00 2001 +Message-Id: <4383e358e2d8a85bd46936c997071c3b776fffd0@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 16 May 2017 10:44:59 +0200 +Subject: [PATCH] conf: add ABI stability checks for IOMMU options +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +https://bugzilla.redhat.com/show_bug.cgi?id=1427005 +(cherry picked from commit 935d927aa881753fff30f6236eedcf9680bca638) +Signed-off-by: Ján Tomko +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 26 ++++++++++++++++++++++++++ + 1 file changed, 26 insertions(+) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 7bf480f2a..370916396 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -19682,6 +19682,16 @@ virDomainDefFeaturesCheckABIStability(virDomainDefPtr src, + } + } + ++ /* ioapic */ ++ if (src->ioapic != dst->ioapic) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("State of ioapic differs: " ++ "source: '%s', destination: '%s'"), ++ virDomainIOAPICTypeToString(src->ioapic), ++ virDomainIOAPICTypeToString(dst->ioapic)); ++ return false; ++ } ++ + return true; + } + +@@ -19821,6 +19831,22 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src, + virDomainIOMMUModelTypeToString(src->model)); + return false; + } ++ if (src->intremap != dst->intremap) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("Target domain IOMMU device intremap value '%s' " ++ "does not match source '%s'"), ++ virTristateSwitchTypeToString(dst->intremap), ++ virTristateSwitchTypeToString(src->intremap)); ++ return false; ++ } ++ if (src->caching_mode != dst->caching_mode) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("Target domain IOMMU device caching mode '%s' " ++ "does not match source '%s'"), ++ virTristateSwitchTypeToString(dst->caching_mode), ++ virTristateSwitchTypeToString(src->caching_mode)); ++ return false; ++ } + return true; + } + +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-add-a-new-parse-flag-VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION.patch b/SOURCES/libvirt-conf-add-a-new-parse-flag-VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION.patch new file mode 100644 index 0000000..6ce10e4 --- /dev/null +++ b/SOURCES/libvirt-conf-add-a-new-parse-flag-VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION.patch @@ -0,0 +1,72 @@ +From b24b004e1196889201142d1fc7d51e2fafdbe328 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Pavel Hrdina +Date: Thu, 20 Apr 2017 09:16:20 +0200 +Subject: [PATCH] conf: add a new parse flag + VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION + +So far there is probably no change that is allowed to be done +by the VIR_DOMAIN_DEF_PARSE_ABI_UPDATE flag that would break +guest ABI but this may change in the future. + +This introduces new VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION +which should be used only for ABI updates that are "safe" for +persistent migration. + +Signed-off-by: Pavel Hrdina +(cherry picked from commit 5c7d88085a762cf4ecc9416a3b7581fa45738c2a) + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373184 + +Signed-off-by: Pavel Hrdina +--- + src/conf/domain_conf.c | 3 ++- + src/conf/domain_conf.h | 4 ++++ + src/qemu/qemu_migration_cookie.c | 2 +- + 3 files changed, 7 insertions(+), 2 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 1b0a55b27..71f0c95c3 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -3805,7 +3805,8 @@ virDomainDefPostParseMemory(virDomainDefPtr def, + /* Attempt to infer the initial memory size from the sum NUMA memory sizes + * in case ABI updates are allowed or the element wasn't specified */ + if (def->mem.total_memory == 0 || +- parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) ++ parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE || ++ parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION) + numaMemory = virDomainNumaGetMemorySize(def->numa); + + /* calculate the sizes of hotplug memory */ +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 47eaacef3..71e651975 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -2725,6 +2725,10 @@ typedef enum { + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE = 1 << 10, + /* skip parsing of security labels */ + VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL = 1 << 11, ++ /* Allows updates in post parse callback for incoming persistent migration ++ * that would break ABI otherwise. This should be used only if it's safe ++ * to do such change. */ ++ VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION = 1 << 12, + } virDomainDefParseFlags; + + typedef enum { +diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c +index bd12f1124..12887892d 100644 +--- a/src/qemu/qemu_migration_cookie.c ++++ b/src/qemu/qemu_migration_cookie.c +@@ -1173,7 +1173,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, + mig->persistent = virDomainDefParseNode(doc, nodes[0], + caps, driver->xmlopt, NULL, + VIR_DOMAIN_DEF_PARSE_INACTIVE | +- VIR_DOMAIN_DEF_PARSE_ABI_UPDATE | ++ VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION | + VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE); + if (!mig->persistent) { + /* virDomainDefParseNode already reported +-- +2.12.2 + diff --git a/SOURCES/libvirt-conf-add-caching_mode-attribute-to-iommu-device.patch b/SOURCES/libvirt-conf-add-caching_mode-attribute-to-iommu-device.patch new file mode 100644 index 0000000..5e209b4 --- /dev/null +++ b/SOURCES/libvirt-conf-add-caching_mode-attribute-to-iommu-device.patch @@ -0,0 +1,196 @@ +From 3b7b827deb9eb7f43f548aabd27c300ae24c7db3 Mon Sep 17 00:00:00 2001 +Message-Id: <3b7b827deb9eb7f43f548aabd27c300ae24c7db3@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 16 May 2017 10:44:56 +0200 +Subject: [PATCH] conf: add caching_mode attribute to iommu device +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add a new attribute to control the caching mode. + +https://bugzilla.redhat.com/show_bug.cgi?id=1427005 +(cherry picked from commit d12781b47eb0c9f3a498d88b632c327aa08aaf8a) +Signed-off-by: Ján Tomko +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 9 ++++ + docs/schemas/domaincommon.rng | 5 +++ + src/conf/domain_conf.c | 24 +++++++++-- + src/conf/domain_conf.h | 1 + + .../qemuxml2argv-intel-iommu-caching-mode.xml | 50 ++++++++++++++++++++++ + .../qemuxml2xmlout-intel-iommu-caching-mode.xml | 1 + + tests/qemuxml2xmltest.c | 1 + + 7 files changed, 88 insertions(+), 3 deletions(-) + create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml + create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index 41b8bfb50..43a75c1ee 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -7424,6 +7424,15 @@ qemu-kvm -net nic,model=? /dev/null + Since 3.4.0 (QEMU/KVM only) +

+ ++
caching_mode
++
++

++ The caching_mode attribute with possible values ++ on and off can be used to ++ turn on the VT-d caching mode (useful for assigned devices). ++ Since 3.4.0 (QEMU/KVM only) ++

++
+ + + +diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng +index a400d961b..12ccbd4e2 100644 +--- a/docs/schemas/domaincommon.rng ++++ b/docs/schemas/domaincommon.rng +@@ -3900,6 +3900,11 @@ + + + ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 45473f65b..e77b542f3 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -14167,6 +14167,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, + iommu->intremap = val; + } + ++ VIR_FREE(tmp); ++ if ((tmp = virXPathString("string(./driver/@caching_mode)", ctxt))) { ++ if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, _("unknown caching_mode value: %s"), tmp); ++ goto cleanup; ++ } ++ iommu->caching_mode = val; ++ } ++ + ret = iommu; + iommu = NULL; + +@@ -24114,9 +24123,18 @@ virDomainIOMMUDefFormat(virBufferPtr buf, + + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + +- if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) { +- virBufferAsprintf(&childBuf, "\n", +- virTristateSwitchTypeToString(iommu->intremap)); ++ if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT || ++ iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) { ++ virBufferAddLit(&childBuf, "intremap != VIR_TRISTATE_SWITCH_ABSENT) { ++ virBufferAsprintf(&childBuf, " intremap='%s'", ++ virTristateSwitchTypeToString(iommu->intremap)); ++ } ++ if (iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) { ++ virBufferAsprintf(&childBuf, " caching_mode='%s'", ++ virTristateSwitchTypeToString(iommu->caching_mode)); ++ } ++ virBufferAddLit(&childBuf, "/>\n"); + } + + virBufferAsprintf(buf, " ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219100 ++ 219100 ++ 1 ++ ++ hvm ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ ++ ++
++ ++ ++ ++ ++
++ ++ ++ ++ ++
++ ++ ++
++ ++ ++
++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml +new file mode 120000 +index 000000000..d971a35dc +--- /dev/null ++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-caching-mode.xml +@@ -0,0 +1 @@ ++../qemuxml2argvdata/qemuxml2argv-intel-iommu-caching-mode.xml +\ No newline at end of file +diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c +index 0482ad9cb..e1938421a 100644 +--- a/tests/qemuxml2xmltest.c ++++ b/tests/qemuxml2xmltest.c +@@ -1129,6 +1129,7 @@ mymain(void) + QEMU_CAPS_MACHINE_OPT, + QEMU_CAPS_MACHINE_IOMMU); + DO_TEST("intel-iommu-ioapic", NONE); ++ DO_TEST("intel-iommu-caching-mode", NONE); + + DO_TEST("cpu-check-none", NONE); + DO_TEST("cpu-check-partial", NONE); +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-add-driver-intremap-to-iommu.patch b/SOURCES/libvirt-conf-add-driver-intremap-to-iommu.patch new file mode 100644 index 0000000..8bd9e7f --- /dev/null +++ b/SOURCES/libvirt-conf-add-driver-intremap-to-iommu.patch @@ -0,0 +1,201 @@ +From 2bb15d3f041ec2506012aa701547334af429b915 Mon Sep 17 00:00:00 2001 +Message-Id: <2bb15d3f041ec2506012aa701547334af429b915@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 16 May 2017 10:44:54 +0200 +Subject: [PATCH] conf: add to +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add a new attribute to control interrupt remapping. + +https://bugzilla.redhat.com/show_bug.cgi?id=1427005 +(cherry picked from commit 2020e2c6f2656ca1aa9032859ccde76185c37c39) +Signed-off-by: Ján Tomko +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 24 +++++++++++++- + docs/schemas/domaincommon.rng | 9 +++++ + src/conf/domain_conf.c | 38 +++++++++++++++++++--- + src/conf/domain_conf.h | 1 + + .../qemuxml2argv-intel-iommu-ioapic.xml | 4 ++- + 5 files changed, 70 insertions(+), 6 deletions(-) + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index 869c1f73e..41b8bfb50 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -7393,7 +7393,9 @@ qemu-kvm -net nic,model=? /dev/null +
+ ...
+ <devices>
+-  <iommu model='intel'/>
++  <iommu model='intel'>
++    <driver intremap='on'/>
++  </iommu>
+ </devices>
+ ...
+ 
+@@ -7404,6 +7406,26 @@ qemu-kvm -net nic,model=? /dev/null + Currently only the intel model is supported. +

+ ++
driver
++
++

++ The driver subelement can be used to configure ++ additional options: ++

++
++
intremap
++
++

++ The intremap attribute with possible values ++ on and off can be used to ++ turn on interrupt remapping, a part of the VT-d functionality. ++ Currently this requires split I/O APIC ++ (<ioapic driver='qemu'/>). ++ Since 3.4.0 (QEMU/KVM only) ++

++
++
++
+ + +

Security label

+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng +index c72ba7e97..a400d961b 100644 +--- a/docs/schemas/domaincommon.rng ++++ b/docs/schemas/domaincommon.rng +@@ -3893,6 +3893,15 @@ + + intel + ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index d5c4f6ddd..45473f65b 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -14132,12 +14132,16 @@ virDomainMemoryDefParseXML(xmlNodePtr memdevNode, + + + static virDomainIOMMUDefPtr +-virDomainIOMMUDefParseXML(xmlNodePtr node) ++virDomainIOMMUDefParseXML(xmlNodePtr node, ++ xmlXPathContextPtr ctxt) + { + virDomainIOMMUDefPtr iommu = NULL, ret = NULL; ++ xmlNodePtr save = ctxt->node; + char *tmp = NULL; + int val; + ++ ctxt->node = node; ++ + if (VIR_ALLOC(iommu) < 0) + goto cleanup; + +@@ -14154,10 +14158,20 @@ virDomainIOMMUDefParseXML(xmlNodePtr node) + + iommu->model = val; + ++ VIR_FREE(tmp); ++ if ((tmp = virXPathString("string(./driver/@intremap)", ctxt))) { ++ if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, _("unknown intremap value: %s"), tmp); ++ goto cleanup; ++ } ++ iommu->intremap = val; ++ } ++ + ret = iommu; + iommu = NULL; + + cleanup: ++ ctxt->node = save; + VIR_FREE(iommu); + VIR_FREE(tmp); + return ret; +@@ -14310,7 +14324,7 @@ virDomainDeviceDefParse(const char *xmlStr, + goto error; + break; + case VIR_DOMAIN_DEVICE_IOMMU: +- if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node))) ++ if (!(dev->data.iommu = virDomainIOMMUDefParseXML(node, ctxt))) + goto error; + break; + case VIR_DOMAIN_DEVICE_NONE: +@@ -18440,7 +18454,7 @@ virDomainDefParseXML(xmlDocPtr xml, + } + + if (n > 0) { +- if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0]))) ++ if (!(def->iommu = virDomainIOMMUDefParseXML(nodes[0], ctxt))) + goto error; + } + VIR_FREE(nodes); +@@ -24096,8 +24110,24 @@ static void + virDomainIOMMUDefFormat(virBufferPtr buf, + const virDomainIOMMUDef *iommu) + { +- virBufferAsprintf(buf, "\n", ++ virBuffer childBuf = VIR_BUFFER_INITIALIZER; ++ ++ virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); ++ ++ if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT) { ++ virBufferAsprintf(&childBuf, "\n", ++ virTristateSwitchTypeToString(iommu->intremap)); ++ } ++ ++ virBufferAsprintf(buf, "model)); ++ if (virBufferUse(&childBuf)) { ++ virBufferAddLit(buf, ">\n"); ++ virBufferAddBuffer(buf, &childBuf); ++ virBufferAddLit(buf, "\n"); ++ } else { ++ virBufferAddLit(buf, "/>\n"); ++ } + } + + +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 4cb37b1fc..8eb422a57 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -2209,6 +2209,7 @@ typedef enum { + + struct _virDomainIOMMUDef { + virDomainIOMMUModel model; ++ virTristateSwitch intremap; + }; + /* + * Guest VM main configuration +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml +index 284d63a30..bfe714ad8 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml ++++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml +@@ -24,6 +24,8 @@ + + + +- ++ ++ ++ + + +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-add-eim-attribute-to-iommu-driver.patch b/SOURCES/libvirt-conf-add-eim-attribute-to-iommu-driver.patch new file mode 100644 index 0000000..8297928 --- /dev/null +++ b/SOURCES/libvirt-conf-add-eim-attribute-to-iommu-driver.patch @@ -0,0 +1,191 @@ +From d7a019948e1c1f0400ee174ef60bf0cb32d181f9 Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 26 May 2017 08:52:56 +0200 +Subject: [PATCH] conf: add eim attribute to +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add an attribute to control extended interrupt mode. + +https://bugzilla.redhat.com/show_bug.cgi?id=1451282 + +Reviewed-by: Andrea Bolognani +(cherry picked from commit dc61d927589b2b122868e6abea86b73caa682226) + +Signed-off-by: Ján Tomko + +Also: +https://bugzilla.redhat.com/show_bug.cgi?id=1289153 +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 13 +++++++++ + docs/schemas/domaincommon.rng | 5 ++++ + src/conf/domain_conf.c | 21 +++++++++++++++ + src/conf/domain_conf.h | 1 + + .../qemuxml2argv-intel-iommu-eim.xml | 31 ++++++++++++++++++++++ + .../qemuxml2xmlout-intel-iommu-eim.xml | 1 + + tests/qemuxml2xmltest.c | 1 + + 7 files changed, 73 insertions(+) + create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml + create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index 43a75c1ee..e886e4e17 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -7433,6 +7433,19 @@ qemu-kvm -net nic,model=? /dev/null + Since 3.4.0 (QEMU/KVM only) +

+ ++
eim
++
++

++ The eim attribute (with possible values ++ on and off) can be used to ++ configure Extended Interrupt Mode. A q35 domain with ++ split I/O APIC (as described in ++ hypervisor features), ++ and both interrupt remapping and EIM turned on for ++ the IOMMU, will be able to use more than 255 vCPUs. ++ Since 3.4.0 (QEMU/KVM only) ++

++
+ + + +diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng +index 12ccbd4e2..af7824aa0 100644 +--- a/docs/schemas/domaincommon.rng ++++ b/docs/schemas/domaincommon.rng +@@ -3905,6 +3905,11 @@ + + + ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 370916396..4404b8f73 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -14176,6 +14176,15 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, + iommu->caching_mode = val; + } + ++ VIR_FREE(tmp); ++ if ((tmp = virXPathString("string(./driver/@eim)", ctxt))) { ++ if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, _("unknown eim value: %s"), tmp); ++ goto cleanup; ++ } ++ iommu->eim = val; ++ } ++ + ret = iommu; + iommu = NULL; + +@@ -19847,6 +19856,14 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src, + virTristateSwitchTypeToString(src->caching_mode)); + return false; + } ++ if (src->eim != dst->eim) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("Target domain IOMMU device eim value '%s' " ++ "does not match source '%s'"), ++ virTristateSwitchTypeToString(dst->eim), ++ virTristateSwitchTypeToString(src->eim)); ++ return false; ++ } + return true; + } + +@@ -24170,6 +24187,10 @@ virDomainIOMMUDefFormat(virBufferPtr buf, + virBufferAsprintf(&childBuf, " caching_mode='%s'", + virTristateSwitchTypeToString(iommu->caching_mode)); + } ++ if (iommu->eim != VIR_TRISTATE_SWITCH_ABSENT) { ++ virBufferAsprintf(&childBuf, " eim='%s'", ++ virTristateSwitchTypeToString(iommu->eim)); ++ } + virBufferAddLit(&childBuf, "/>\n"); + } + +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 825158a7d..980aafa66 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -2211,6 +2211,7 @@ struct _virDomainIOMMUDef { + virDomainIOMMUModel model; + virTristateSwitch intremap; + virTristateSwitch caching_mode; ++ virTristateSwitch eim; + }; + /* + * Guest VM main configuration +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml +new file mode 100644 +index 000000000..8642ed349 +--- /dev/null ++++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml +@@ -0,0 +1,31 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219100 ++ 219100 ++ 288 ++ ++ hvm ++ ++ ++ ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml +new file mode 120000 +index 000000000..9fbec36dc +--- /dev/null ++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-eim.xml +@@ -0,0 +1 @@ ++../qemuxml2argvdata/qemuxml2argv-intel-iommu-eim.xml +\ No newline at end of file +diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c +index e1938421a..6283da409 100644 +--- a/tests/qemuxml2xmltest.c ++++ b/tests/qemuxml2xmltest.c +@@ -1130,6 +1130,7 @@ mymain(void) + QEMU_CAPS_MACHINE_IOMMU); + DO_TEST("intel-iommu-ioapic", NONE); + DO_TEST("intel-iommu-caching-mode", NONE); ++ DO_TEST("intel-iommu-eim", NONE); + + DO_TEST("cpu-check-none", NONE); + DO_TEST("cpu-check-partial", NONE); +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-add-ioapic-driver-to-features.patch b/SOURCES/libvirt-conf-add-ioapic-driver-to-features.patch new file mode 100644 index 0000000..c7b34fa --- /dev/null +++ b/SOURCES/libvirt-conf-add-ioapic-driver-to-features.patch @@ -0,0 +1,249 @@ +From abbea18f4b3747d738d05f36884dda3202128b65 Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 16 May 2017 10:44:52 +0200 +Subject: [PATCH] conf: add to +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add a new element with a driver attribute. + +Possible values are qemu and kvm. With 'qemu', the I/O +APIC can be put in the userspace even for KVM domains. + +https://bugzilla.redhat.com/show_bug.cgi?id=1427005 +(cherry picked from commit 8023b21a95f271e51810de7f1362e609eaadc1e4) +Signed-off-by: Ján Tomko +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 9 ++++++ + docs/schemas/domaincommon.rng | 15 ++++++++++ + src/conf/domain_conf.c | 33 +++++++++++++++++++++- + src/conf/domain_conf.h | 11 ++++++++ + .../qemuxml2argv-intel-iommu-ioapic.xml | 29 +++++++++++++++++++ + .../qemuxml2xmlout-intel-iommu-ioapic.xml | 1 + + tests/qemuxml2xmltest.c | 1 + + 7 files changed, 98 insertions(+), 1 deletion(-) + create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml + create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index 7e55b0327..869c1f73e 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -1675,6 +1675,7 @@ + </kvm> + <pvspinlock state='on'/> + <gic version='2'/> ++ <ioapic driver='qemu'/> + + </features> + ... +@@ -1836,6 +1837,14 @@ + for hypervisor to decide. + Since 2.1.0 + ++
ioapic
++
Tune the I/O APIC. Possible values for the ++ driver attribute are: ++ kvm (default for KVM domains) ++ and qemu which puts I/O APIC in userspace ++ which is also known as a split I/O APIC mode. ++ Since 3.4.0 (QEMU/KVM only) ++
+ + +

Time keeping

+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng +index 7271f0113..c72ba7e97 100644 +--- a/docs/schemas/domaincommon.rng ++++ b/docs/schemas/domaincommon.rng +@@ -4515,6 +4515,9 @@ + + + ++ ++ ++ + + + +@@ -4693,6 +4696,18 @@ + + + ++ ++ ++ ++ ++ qemu ++ kvm ++ ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 4096b9caf..d5c4f6ddd 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -141,7 +141,8 @@ VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, + "pmu", + "vmport", + "gic", +- "smm") ++ "smm", ++ "ioapic") + + VIR_ENUM_IMPL(virDomainCapabilitiesPolicy, VIR_DOMAIN_CAPABILITIES_POLICY_LAST, + "default", +@@ -859,6 +860,11 @@ VIR_ENUM_IMPL(virDomainLoader, + "rom", + "pflash") + ++VIR_ENUM_IMPL(virDomainIOAPIC, ++ VIR_DOMAIN_IOAPIC_LAST, ++ "qemu", ++ "kvm") ++ + /* Internal mapping: subset of block job types that can be present in + * XML (remaining types are not two-phase). */ + VIR_ENUM_DECL(virDomainBlockJob) +@@ -17518,6 +17524,24 @@ virDomainDefParseXML(xmlDocPtr xml, + ctxt->node = node; + break; + ++ case VIR_DOMAIN_FEATURE_IOAPIC: ++ node = ctxt->node; ++ ctxt->node = nodes[i]; ++ tmp = virXPathString("string(./@driver)", ctxt); ++ if (tmp) { ++ int value = virDomainIOAPICTypeFromString(tmp); ++ if (value < 0) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("Unknown driver mode: %s"), ++ tmp); ++ goto error; ++ } ++ def->ioapic = value; ++ def->features[val] = VIR_TRISTATE_SWITCH_ON; ++ } ++ ctxt->node = node; ++ break; ++ + /* coverity[dead_error_begin] */ + case VIR_DOMAIN_FEATURE_LAST: + break; +@@ -24598,6 +24622,13 @@ virDomainDefFormatInternal(virDomainDefPtr def, + } + break; + ++ case VIR_DOMAIN_FEATURE_IOAPIC: ++ if (def->features[i] == VIR_TRISTATE_SWITCH_ON) { ++ virBufferAsprintf(buf, "\n", ++ virDomainIOAPICTypeToString(def->ioapic)); ++ } ++ break; ++ + /* coverity[dead_error_begin] */ + case VIR_DOMAIN_FEATURE_LAST: + break; +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index f1e9fc2ba..4cb37b1fc 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -1670,6 +1670,7 @@ typedef enum { + VIR_DOMAIN_FEATURE_VMPORT, + VIR_DOMAIN_FEATURE_GIC, + VIR_DOMAIN_FEATURE_SMM, ++ VIR_DOMAIN_FEATURE_IOAPIC, + + VIR_DOMAIN_FEATURE_LAST + } virDomainFeature; +@@ -1809,6 +1810,15 @@ struct _virDomainLoaderDef { + + void virDomainLoaderDefFree(virDomainLoaderDefPtr loader); + ++typedef enum { ++ VIR_DOMAIN_IOAPIC_QEMU = 0, ++ VIR_DOMAIN_IOAPIC_KVM, ++ ++ VIR_DOMAIN_IOAPIC_LAST ++} virDomainIOAPIC; ++ ++VIR_ENUM_DECL(virDomainIOAPIC); ++ + /* Operating system configuration data & machine / arch */ + typedef struct _virDomainOSDef virDomainOSDef; + typedef virDomainOSDef *virDomainOSDefPtr; +@@ -2258,6 +2268,7 @@ struct _virDomainDef { + unsigned int hyperv_spinlocks; + virGICVersion gic_version; + char *hyperv_vendor_id; ++ virDomainIOAPIC ioapic; + + /* These options are of type virTristateSwitch: ON = keep, OFF = drop */ + int caps_features[VIR_DOMAIN_CAPS_FEATURE_LAST]; +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml +new file mode 100644 +index 000000000..284d63a30 +--- /dev/null ++++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml +@@ -0,0 +1,29 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219100 ++ 219100 ++ 1 ++ ++ hvm ++ ++ ++ ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ ++
++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml +new file mode 120000 +index 000000000..42d17b2c0 +--- /dev/null ++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-ioapic.xml +@@ -0,0 +1 @@ ++../qemuxml2argvdata/qemuxml2argv-intel-iommu-ioapic.xml +\ No newline at end of file +diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c +index ff533ab19..0482ad9cb 100644 +--- a/tests/qemuxml2xmltest.c ++++ b/tests/qemuxml2xmltest.c +@@ -1128,6 +1128,7 @@ mymain(void) + DO_TEST("intel-iommu-machine", + QEMU_CAPS_MACHINE_OPT, + QEMU_CAPS_MACHINE_IOMMU); ++ DO_TEST("intel-iommu-ioapic", NONE); + + DO_TEST("cpu-check-none", NONE); + DO_TEST("cpu-check-partial", NONE); +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-add-iotlb-attribute-to-iommu.patch b/SOURCES/libvirt-conf-add-iotlb-attribute-to-iommu.patch new file mode 100644 index 0000000..d8b4894 --- /dev/null +++ b/SOURCES/libvirt-conf-add-iotlb-attribute-to-iommu.patch @@ -0,0 +1,194 @@ +From 1e915e38d422df8b3cb4e049e932a5e6900735bc Mon Sep 17 00:00:00 2001 +Message-Id: <1e915e38d422df8b3cb4e049e932a5e6900735bc@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:48:56 +0200 +Subject: [PATCH] conf: add iotlb attribute to iommu +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Add a new iotlb attribute to the iommu device +to control the device IOTLB support for intel-iommu. + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 + +Reviewed-by: Pavel Hrdina +(cherry picked from commit 27b187be3988c60cd26e08ab4bcab66bed5a3646) +Signed-off-by: Ján Tomko +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 10 +++++++ + docs/schemas/domaincommon.rng | 5 ++++ + src/conf/domain_conf.c | 23 +++++++++++++++- + src/conf/domain_conf.h | 1 + + .../qemuxml2argv-intel-iommu-device-iotlb.xml | 31 ++++++++++++++++++++++ + .../qemuxml2xmlout-intel-iommu-device-iotlb.xml | 1 + + tests/qemuxml2xmltest.c | 1 + + 7 files changed, 71 insertions(+), 1 deletion(-) + create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml + create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index e886e4e17e..e8a3367bac 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -7446,6 +7446,16 @@ qemu-kvm -net nic,model=? /dev/null + Since 3.4.0 (QEMU/KVM only) +

+ ++
iotlb
++
++

++ The iotlb attribute with possible values ++ on and off can be used to ++ turn on the IOTLB used to cache address translation ++ requests from devices. ++ Since 3.5.0 (QEMU/KVM only) ++

++
+ + + +diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng +index af7824aa02..1b66362f17 100644 +--- a/docs/schemas/domaincommon.rng ++++ b/docs/schemas/domaincommon.rng +@@ -3910,6 +3910,11 @@ + + + ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 275145b1ec..701a6d2136 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -14196,6 +14196,14 @@ virDomainIOMMUDefParseXML(xmlNodePtr node, + } + iommu->caching_mode = val; + } ++ VIR_FREE(tmp); ++ if ((tmp = virXPathString("string(./driver/@iotlb)", ctxt))) { ++ if ((val = virTristateSwitchTypeFromString(tmp)) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, _("unknown iotlb value: %s"), tmp); ++ goto cleanup; ++ } ++ iommu->iotlb = val; ++ } + + VIR_FREE(tmp); + if ((tmp = virXPathString("string(./driver/@eim)", ctxt))) { +@@ -19877,6 +19885,14 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src, + virTristateSwitchTypeToString(src->eim)); + return false; + } ++ if (src->iotlb != dst->iotlb) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("Target domain IOMMU device iotlb value '%s' " ++ "does not match source '%s'"), ++ virTristateSwitchTypeToString(dst->iotlb), ++ virTristateSwitchTypeToString(src->iotlb)); ++ return false; ++ } + return true; + } + +@@ -24212,7 +24228,8 @@ virDomainIOMMUDefFormat(virBufferPtr buf, + virBufferAdjustIndent(&childBuf, virBufferGetIndent(buf, false) + 2); + + if (iommu->intremap != VIR_TRISTATE_SWITCH_ABSENT || +- iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT) { ++ iommu->caching_mode != VIR_TRISTATE_SWITCH_ABSENT || ++ iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAddLit(&childBuf, "intremap != VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&childBuf, " intremap='%s'", +@@ -24226,6 +24243,10 @@ virDomainIOMMUDefFormat(virBufferPtr buf, + virBufferAsprintf(&childBuf, " eim='%s'", + virTristateSwitchTypeToString(iommu->eim)); + } ++ if (iommu->iotlb != VIR_TRISTATE_SWITCH_ABSENT) { ++ virBufferAsprintf(&childBuf, " iotlb='%s'", ++ virTristateSwitchTypeToString(iommu->iotlb)); ++ } + virBufferAddLit(&childBuf, "/>\n"); + } + +diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h +index 706d106ad9..e6c20a9e1e 100644 +--- a/src/conf/domain_conf.h ++++ b/src/conf/domain_conf.h +@@ -2213,6 +2213,7 @@ struct _virDomainIOMMUDef { + virTristateSwitch intremap; + virTristateSwitch caching_mode; + virTristateSwitch eim; ++ virTristateSwitch iotlb; + }; + /* + * Guest VM main configuration +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml +new file mode 100644 +index 0000000000..3eb08ab9af +--- /dev/null ++++ b/tests/qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml +@@ -0,0 +1,31 @@ ++ ++ QEMUGuest1 ++ c7a5fdbd-edaf-9455-926a-d65c16db1809 ++ 219100 ++ 219100 ++ 1 ++ ++ hvm ++ ++ ++ ++ ++ ++ ++ destroy ++ restart ++ destroy ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml +new file mode 120000 +index 0000000000..3120d9f677 +--- /dev/null ++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-intel-iommu-device-iotlb.xml +@@ -0,0 +1 @@ ++../qemuxml2argvdata/qemuxml2argv-intel-iommu-device-iotlb.xml +\ No newline at end of file +diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c +index 6283da4096..3f7c268e43 100644 +--- a/tests/qemuxml2xmltest.c ++++ b/tests/qemuxml2xmltest.c +@@ -1131,6 +1131,7 @@ mymain(void) + DO_TEST("intel-iommu-ioapic", NONE); + DO_TEST("intel-iommu-caching-mode", NONE); + DO_TEST("intel-iommu-eim", NONE); ++ DO_TEST("intel-iommu-device-iotlb", NONE); + + DO_TEST("cpu-check-none", NONE); + DO_TEST("cpu-check-partial", NONE); +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-allow-hotplugging-legacy-PCI-device-to-manually-addressed-PCIe-slot.patch b/SOURCES/libvirt-conf-allow-hotplugging-legacy-PCI-device-to-manually-addressed-PCIe-slot.patch deleted file mode 100644 index ae2aecf..0000000 --- a/SOURCES/libvirt-conf-allow-hotplugging-legacy-PCI-device-to-manually-addressed-PCIe-slot.patch +++ /dev/null @@ -1,54 +0,0 @@ -From 58593f4340d766fb7639de542f3b21463d5b98ef Mon Sep 17 00:00:00 2001 -Message-Id: <58593f4340d766fb7639de542f3b21463d5b98ef@dist-git> -From: Laine Stump -Date: Mon, 12 Sep 2016 16:25:25 -0400 -Subject: [PATCH] conf: allow hotplugging "legacy PCI" device to manually - addressed PCIe slot - -In a full domain config, libvirt allows overriding the normal PCI -vs. PCI Express rules when a device address is explicitly provided -(so, e.g., you can force a legacy PCI device to plug into a PCIe port, -although libvirt would never do that on its own). However, due to a -bug libvirt doesn't give this same leeway when hotplugging devices. On -top of that, current libvirt assumes that *all* devices are legacy -PCI. The result of all this is that it's impossible to hotplug a -device into a PCIe port, even if you manually add the PCI address. - -This can all be traced to the function -virDomainPCIAddressEnsureAddr(), and the fact that it calls -virDomainPCIaddressReserveSlot() for manually set addresses, and that -function hardcodes the argument "fromConfig" to false (meaning "this -address was auto-assigned, so it should be subject to stricter -validation"). - -Since virDomainPCIAddressReserveSlot() is just a one line simple -wrapper around virDomainPCIAddressReserveAddr() (adding in a hardcoded -reserveEntireSlot = true and fromConfig = false), all that's needed to -solve the problem with no unwanted side effects is to replace that -call for virDomainPCIAddressReserveSlot() with a direct call to -virDomainPCIAddressReserveAddr(), but with reserveEntireSlot = true, -fromConfig = true. That's what this patch does. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1337490 -(cherry picked from commit b87703cf79559157404667628802d7fe8f9f19a6) ---- - src/conf/domain_addr.c | 3 ++- - 1 file changed, 2 insertions(+), 1 deletion(-) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 7f4f4d8..cad1c27 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -507,7 +507,8 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs, - addrStr, flags, true)) - goto cleanup; - -- ret = virDomainPCIAddressReserveSlot(addrs, &dev->addr.pci, flags); -+ ret = virDomainPCIAddressReserveAddr(addrs, &dev->addr.pci, flags, -+ true, true); - } else { - ret = virDomainPCIAddressReserveNextSlot(addrs, dev, flags); - } --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-convert-def-vcpus-to-a-array-of-pointers.patch b/SOURCES/libvirt-conf-convert-def-vcpus-to-a-array-of-pointers.patch deleted file mode 100644 index 18dcbd5..0000000 --- a/SOURCES/libvirt-conf-convert-def-vcpus-to-a-array-of-pointers.patch +++ /dev/null @@ -1,174 +0,0 @@ -From 909fa8d0e46a086da4ab44d40b652b8fe2917df4 Mon Sep 17 00:00:00 2001 -Message-Id: <909fa8d0e46a086da4ab44d40b652b8fe2917df4@dist-git> -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:10:47 -0400 -Subject: [PATCH] conf: convert def->vcpus to a array of pointers - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -(cherry picked from commit 990b06de03b3f4e294e3e9eca831fea7b1edb067) ---- - src/conf/domain_conf.c | 44 +++++++++++++++++++++++++++++++------------- - src/conf/domain_conf.h | 2 +- - 2 files changed, 32 insertions(+), 14 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 7a12462..6d0f967 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -1312,14 +1312,26 @@ void virDomainLeaseDefFree(virDomainLeaseDefPtr def) - } - - -+static virDomainVcpuDefPtr -+virDomainVcpuDefNew(void) -+{ -+ virDomainVcpuDefPtr ret; -+ -+ ignore_value(VIR_ALLOC(ret)); -+ -+ return ret; -+} -+ -+ - static void --virDomainVcpuDefClear(virDomainVcpuDefPtr info) -+virDomainVcpuDefFree(virDomainVcpuDefPtr info) - { - if (!info) - return; - - virBitmapFree(info->cpumask); - info->cpumask = NULL; -+ VIR_FREE(info); - } - - -@@ -1327,6 +1339,7 @@ int - virDomainDefSetVcpusMax(virDomainDefPtr def, - unsigned int maxvcpus) - { -+ size_t oldmax = def->maxvcpus; - size_t i; - - if (def->maxvcpus == maxvcpus) -@@ -1335,9 +1348,14 @@ virDomainDefSetVcpusMax(virDomainDefPtr def, - if (def->maxvcpus < maxvcpus) { - if (VIR_EXPAND_N(def->vcpus, def->maxvcpus, maxvcpus - def->maxvcpus) < 0) - return -1; -+ -+ for (i = oldmax; i < def->maxvcpus; i++) { -+ if (!(def->vcpus[i] = virDomainVcpuDefNew())) -+ return -1; -+ } - } else { - for (i = maxvcpus; i < def->maxvcpus; i++) -- virDomainVcpuDefClear(&def->vcpus[i]); -+ virDomainVcpuDefFree(def->vcpus[i]); - - VIR_SHRINK_N(def->vcpus, def->maxvcpus, def->maxvcpus - maxvcpus); - } -@@ -1352,7 +1370,7 @@ virDomainDefHasVcpusOffline(const virDomainDef *def) - size_t i; - - for (i = 0; i < def->maxvcpus; i++) { -- if (!def->vcpus[i].online) -+ if (!def->vcpus[i]->online) - return true; - } - -@@ -1381,10 +1399,10 @@ virDomainDefSetVcpus(virDomainDefPtr def, - } - - for (i = 0; i < vcpus; i++) -- def->vcpus[i].online = true; -+ def->vcpus[i]->online = true; - - for (i = vcpus; i < def->maxvcpus; i++) -- def->vcpus[i].online = false; -+ def->vcpus[i]->online = false; - - return 0; - } -@@ -1397,7 +1415,7 @@ virDomainDefGetVcpus(const virDomainDef *def) - unsigned int ret = 0; - - for (i = 0; i < def->maxvcpus; i++) { -- if (def->vcpus[i].online) -+ if (def->vcpus[i]->online) - ret++; - } - -@@ -1421,7 +1439,7 @@ virDomainDefGetOnlineVcpumap(const virDomainDef *def) - return NULL; - - for (i = 0; i < def->maxvcpus; i++) { -- if (def->vcpus[i].online) -+ if (def->vcpus[i]->online) - ignore_value(virBitmapSetBit(ret, i)); - } - -@@ -1436,7 +1454,7 @@ virDomainDefGetVcpu(virDomainDefPtr def, - if (vcpu >= def->maxvcpus) - return NULL; - -- return &def->vcpus[vcpu]; -+ return def->vcpus[vcpu]; - } - - -@@ -1465,7 +1483,7 @@ virDomainDefHasVcpuPin(const virDomainDef *def) - size_t i; - - for (i = 0; i < def->maxvcpus; i++) { -- if (def->vcpus[i].cpumask) -+ if (def->vcpus[i]->cpumask) - return true; - } - -@@ -2526,7 +2544,7 @@ void virDomainDefFree(virDomainDefPtr def) - virDomainResourceDefFree(def->resource); - - for (i = 0; i < def->maxvcpus; i++) -- virDomainVcpuDefClear(&def->vcpus[i]); -+ virDomainVcpuDefFree(def->vcpus[i]); - VIR_FREE(def->vcpus); - - /* hostdevs must be freed before nets (or any future "intelligent -@@ -18634,8 +18652,8 @@ virDomainDefVcpuCheckAbiStability(virDomainDefPtr src, - } - - for (i = 0; i < src->maxvcpus; i++) { -- virDomainVcpuDefPtr svcpu = &src->vcpus[i]; -- virDomainVcpuDefPtr dvcpu = &dst->vcpus[i]; -+ virDomainVcpuDefPtr svcpu = src->vcpus[i]; -+ virDomainVcpuDefPtr dvcpu = dst->vcpus[i]; - - if (svcpu->online != dvcpu->online) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -@@ -22819,7 +22837,7 @@ virDomainCputuneDefFormat(virBufferPtr buf, - - for (i = 0; i < def->maxvcpus; i++) { - char *cpumask; -- virDomainVcpuDefPtr vcpu = def->vcpus + i; -+ virDomainVcpuDefPtr vcpu = def->vcpus[i]; - - if (!vcpu->cpumask) - continue; -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index c20ea79..ac37382 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -2132,7 +2132,7 @@ struct _virDomainDef { - virDomainBlkiotune blkio; - virDomainMemtune mem; - -- virDomainVcpuDefPtr vcpus; -+ virDomainVcpuDefPtr *vcpus; - size_t maxvcpus; - int placement_mode; - virBitmapPtr cpumask; --- -2.10.0 - diff --git a/SOURCES/libvirt-conf-docs-Add-support-for-coalesce-setting-s.patch b/SOURCES/libvirt-conf-docs-Add-support-for-coalesce-setting-s.patch new file mode 100644 index 0000000..f7166fc --- /dev/null +++ b/SOURCES/libvirt-conf-docs-Add-support-for-coalesce-setting-s.patch @@ -0,0 +1,557 @@ +From 705cbf8998e405b98f2d536f6d92c524755fe219 Mon Sep 17 00:00:00 2001 +Message-Id: <705cbf8998e405b98f2d536f6d92c524755fe219@dist-git> +From: Martin Kletzander +Date: Tue, 25 Apr 2017 13:41:16 +0200 +Subject: [PATCH] conf, docs: Add support for coalesce setting(s) + +https://bugzilla.redhat.com/show_bug.cgi?id=1414627 + +We are currently parsing only rx/frames/max because that's the only +value that makes sense for us. The tun device just added support for +this one and the others are only supported by hardware devices which +we don't need to worry about as the only way we'd pass those to the +domain is using or . And in +those cases the guest can modify the settings itself. + +Signed-off-by: Martin Kletzander +(cherry picked from commit 523c9960621eaf307ae8d4ae2735fb66f89d5634) +Signed-off-by: Martin Kletzander +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 27 +++++ + docs/schemas/domaincommon.rng | 131 +++++++++++++++++++++ + src/conf/domain_conf.c | 80 +++++++++++++ + src/conf/domain_conf.h | 2 + + src/qemu/qemu_domain.c | 31 +++++ + .../qemuxml2argvdata/qemuxml2argv-net-coalesce.xml | 68 +++++++++++ + .../qemuxml2xmlout-net-coalesce.xml | 71 +++++++++++ + tests/qemuxml2xmltest.c | 1 + + 8 files changed, 411 insertions(+) + create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml + create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index aee1e1442..7374cb243 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -5437,6 +5437,33 @@ qemu-kvm -net nic,model=? /dev/null + Since 3.1.0 +

+ ++
Coalesce settings
++
++...
++<devices>
++  <interface type='network'>
++    <source network='default'/>
++    <target dev='vnet0'/>
++    <coalesce>
++      <rx>
++        <frames max='7'/>
++      </rx>
++    </coalesce>
++  </interface>
++</devices>
++...
++ ++

++ This element provides means of setting coalesce settings for ++ some interface devices (currently only type network ++ and bridge. Currently there is just one attribute, ++ max, to tweak, in element frames for ++ the rx group, which accepts a non-negative integer ++ that specifies the maximum number of packets that will be ++ received before an interrupt. ++ Since 3.3.0 ++

++ +
IP configuration
+
+ ...
+diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
+index d5c28ee3c..7a9b4b702 100644
+--- a/docs/schemas/domaincommon.rng
++++ b/docs/schemas/domaincommon.rng
+@@ -2509,6 +2509,9 @@
+         
+       
+       
++        
++      
++      
+         
+           
+             
+@@ -5746,4 +5749,132 @@
+       
+     
+   
++
++  
++    
++      
++        
++          
++            
++              
++                
++                  
++                    
++                  
++                
++                
++              
++            
++            
++          
++        
++        
++      
++    
++  
++
+ 
+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
+index 71f0c95c3..f2801ec84 100644
+--- a/src/conf/domain_conf.c
++++ b/src/conf/domain_conf.c
+@@ -6759,6 +6759,77 @@ virDomainNetIPInfoParseXML(const char *source,
+     return ret;
+ }
+ 
++
++static virNetDevCoalescePtr
++virDomainNetDefCoalesceParseXML(xmlNodePtr node,
++                                xmlXPathContextPtr ctxt)
++{
++    virNetDevCoalescePtr ret = NULL;
++    xmlNodePtr save = NULL;
++    char *str = NULL;
++    unsigned long long tmp = 0;
++
++    save = ctxt->node;
++    ctxt->node = node;
++
++    str = virXPathString("string(./rx/frames/@max)", ctxt);
++    if (!str)
++        goto cleanup;
++
++    if (!ret && VIR_ALLOC(ret) < 0)
++        goto cleanup;
++
++    if (virStrToLong_ullp(str, NULL, 10, &tmp) < 0) {
++        virReportError(VIR_ERR_XML_DETAIL,
++                       _("cannot parse value '%s' for coalesce parameter"),
++                       str);
++        VIR_FREE(str);
++        goto error;
++    }
++    VIR_FREE(str);
++
++    if (tmp > UINT32_MAX) {
++        virReportError(VIR_ERR_OVERFLOW,
++                       _("value '%llu' is too big for coalesce "
++                         "parameter, maximum is '%lu'"),
++                       tmp, (unsigned long) UINT32_MAX);
++        goto error;
++    }
++    ret->rx_max_coalesced_frames = tmp;
++
++ cleanup:
++    ctxt->node = save;
++    return ret;
++
++ error:
++    VIR_FREE(ret);
++    goto cleanup;
++}
++
++static void
++virDomainNetDefCoalesceFormatXML(virBufferPtr buf,
++                                 virNetDevCoalescePtr coalesce)
++{
++    if (!coalesce || !coalesce->rx_max_coalesced_frames)
++        return;
++
++    virBufferAddLit(buf, "\n");
++    virBufferAdjustIndent(buf, 2);
++
++    virBufferAddLit(buf, "\n");
++    virBufferAdjustIndent(buf, 2);
++
++    virBufferAsprintf(buf, "\n",
++                      coalesce->rx_max_coalesced_frames);
++
++    virBufferAdjustIndent(buf, -2);
++    virBufferAddLit(buf, "\n");
++
++    virBufferAdjustIndent(buf, -2);
++    virBufferAddLit(buf, "\n");
++}
++
++
+ static int
+ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
+                                 xmlXPathContextPtr ctxt,
+@@ -10242,6 +10313,13 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt,
+         goto error;
+     }
+ 
++    node = virXPathNode("./coalesce", ctxt);
++    if (node) {
++        def->coalesce = virDomainNetDefCoalesceParseXML(node, ctxt);
++        if (!def->coalesce)
++            goto error;
++    }
++
+  cleanup:
+     ctxt->node = oldnode;
+     VIR_FREE(macaddr);
+@@ -22135,6 +22213,8 @@ virDomainNetDefFormat(virBufferPtr buf,
+     if (def->mtu)
+         virBufferAsprintf(buf, "\n", def->mtu);
+ 
++    virDomainNetDefCoalesceFormatXML(buf, def->coalesce);
++
+     if (virDomainDeviceInfoFormat(buf, &def->info,
+                                   flags | VIR_DOMAIN_DEF_FORMAT_ALLOW_BOOT
+                                   | VIR_DOMAIN_DEF_FORMAT_ALLOW_ROM) < 0)
+diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
+index 71e651975..1dbbcdc51 100644
+--- a/src/conf/domain_conf.h
++++ b/src/conf/domain_conf.h
+@@ -41,6 +41,7 @@
+ # include "numa_conf.h"
+ # include "virnetdevmacvlan.h"
+ # include "virsysinfo.h"
++# include "virnetdev.h"
+ # include "virnetdevip.h"
+ # include "virnetdevvportprofile.h"
+ # include "virnetdevbandwidth.h"
+@@ -1036,6 +1037,7 @@ struct _virDomainNetDef {
+     int trustGuestRxFilters; /* enum virTristateBool */
+     int linkstate;
+     unsigned int mtu;
++    virNetDevCoalescePtr coalesce;
+ };
+ 
+ /* Used for prefix of ifname of any network name generated dynamically
+diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
+index d31645fd1..53586878b 100644
+--- a/src/qemu/qemu_domain.c
++++ b/src/qemu/qemu_domain.c
+@@ -3012,6 +3012,30 @@ qemuDomainDefValidate(const virDomainDef *def,
+ }
+ 
+ 
++static bool
++qemuDomainNetSupportsCoalesce(virDomainNetType type)
++{
++    switch (type) {
++    case VIR_DOMAIN_NET_TYPE_NETWORK:
++    case VIR_DOMAIN_NET_TYPE_BRIDGE:
++        return true;
++    case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
++    case VIR_DOMAIN_NET_TYPE_ETHERNET:
++    case VIR_DOMAIN_NET_TYPE_DIRECT:
++    case VIR_DOMAIN_NET_TYPE_HOSTDEV:
++    case VIR_DOMAIN_NET_TYPE_USER:
++    case VIR_DOMAIN_NET_TYPE_SERVER:
++    case VIR_DOMAIN_NET_TYPE_CLIENT:
++    case VIR_DOMAIN_NET_TYPE_MCAST:
++    case VIR_DOMAIN_NET_TYPE_INTERNAL:
++    case VIR_DOMAIN_NET_TYPE_UDP:
++    case VIR_DOMAIN_NET_TYPE_LAST:
++        break;
++    }
++    return false;
++}
++
++
+ static int
+ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                             const virDomainDef *def ATTRIBUTE_UNUSED,
+@@ -3046,6 +3070,13 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev,
+                            virDomainNetTypeToString(net->type));
+             goto cleanup;
+         }
++
++        if (net->coalesce && !qemuDomainNetSupportsCoalesce(net->type)) {
++            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
++                           _("coalesce settings on interface type %s are not supported"),
++                           virDomainNetTypeToString(net->type));
++            goto cleanup;
++        }
+     }
+ 
+     ret = 0;
+diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml b/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
+new file mode 100644
+index 000000000..b51032442
+--- /dev/null
++++ b/tests/qemuxml2argvdata/qemuxml2argv-net-coalesce.xml
+@@ -0,0 +1,68 @@
++
++  test
++  15d091de-0181-456b-9554-e4382dc1f1ab
++  1048576
++  1048576
++  1
++  
++    hvm
++    
++    
++    
++  
++  
++  destroy
++  restart
++  restart
++  
++    /usr/bin/qemu-system-x86_64
++    
++      
++      
++      
++      
++ ++ ++ ++ ++ ++ ++
++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml +new file mode 100644 +index 000000000..fd5fdbece +--- /dev/null ++++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-net-coalesce.xml +@@ -0,0 +1,71 @@ ++ ++ test ++ 15d091de-0181-456b-9554-e4382dc1f1ab ++ 1048576 ++ 1048576 ++ 1 ++ ++ hvm ++ ++ ++ ++ ++ ++ destroy ++ restart ++ restart ++ ++ /usr/bin/qemu-system-x86_64 ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++
++ ++ ++
++ ++ ++
++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++
++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
++ ++ ++ +diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c +index eae999dd6..26a2259fd 100644 +--- a/tests/qemuxml2xmltest.c ++++ b/tests/qemuxml2xmltest.c +@@ -532,6 +532,7 @@ mymain(void) + DO_TEST("net-bandwidth", NONE); + DO_TEST("net-bandwidth2", NONE); + DO_TEST("net-mtu", NONE); ++ DO_TEST("net-coalesce", NONE); + + DO_TEST("serial-vc", NONE); + DO_TEST("serial-pty", NONE); +-- +2.12.2 + diff --git a/SOURCES/libvirt-conf-don-t-allow-connecting-upstream-port-directly-to-pce-expander-bus.patch b/SOURCES/libvirt-conf-don-t-allow-connecting-upstream-port-directly-to-pce-expander-bus.patch deleted file mode 100644 index 32d357e..0000000 --- a/SOURCES/libvirt-conf-don-t-allow-connecting-upstream-port-directly-to-pce-expander-bus.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 093fe7d6bde7f224200e7f2877949f3196002bd7 Mon Sep 17 00:00:00 2001 -Message-Id: <093fe7d6bde7f224200e7f2877949f3196002bd7@dist-git> -From: Laine Stump -Date: Wed, 10 Aug 2016 11:00:12 -0400 -Subject: [PATCH] conf: don't allow connecting upstream-port directly to - pce-expander-bus - -I apparently misunderstood Marcel's description of what could and -couldn't be plugged into qemu's pxb-pcie controller (known as -pcie-expander-bus in libvirt) - I specifically allowed directly -connecting a pcie-switch-upstream-port, and it turns out that causes -the guest kernel to crash. - -This patch forbids such a connection, and updates the xml docs -appropriately. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1361172 -(cherry picked from commit b70e54342bbd1756234e07ed6b22bdd3cd12b689) ---- - docs/formatdomain.html.in | 20 +++++++++++--------- - src/conf/domain_addr.c | 7 ++----- - 2 files changed, 13 insertions(+), 14 deletions(-) - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index c2e261d..b74057f 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -3333,15 +3333,17 @@ - 2nd bus-number is just being reserved for the pcie-root-port - that must necessarily be connected to the bus in order to - actually plug in an endpoint device. If you intend to plug -- multiple devices into a pcie-expander-bus, you must instead -- connect a pcie-switch-upstream-port to the -- pcie-expander-bus, and multiple pcie-switch-downstream-ports -- to the pcie-switch-downstream-port, and of course for this -- to work properly, you will need to decrease the -- pcie-expander-bus' busNr accordingly so that there are -- enough unused bus numbers above it to accomodate giving out -- one bus number for the upstream-port and one for each -- downstream-port). -+ multiple devices into a pcie-expander-bus, you must connect -+ a pcie-switch-upstream-port to the pcie-root-port that is -+ plugged into the pcie-expander-bus, and multiple -+ pcie-switch-downstream-ports to the -+ pcie-switch-upstream-port, and of course for this to work -+ properly, you will need to decrease the pcie-expander-bus' -+ busNr accordingly so that there are enough unused bus -+ numbers above it to accomodate giving out one bus number for -+ the upstream-port and one for each downstream-port (in -+ addition to the pcie-root-port and the pcie-expander-bus -+ itself). -

- -
node
-diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 61c4074..c22329d 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -291,11 +291,8 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, - bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST; - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: -- /* single slot, no hotplug, only accepts pcie-root-port or -- * pcie-switch-upstream-port. -- */ -- bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT -- | VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT); -+ /* single slot, no hotplug, only accepts pcie-root-port */ -+ bus->flags = VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT; - bus->minSlot = 0; - bus->maxSlot = 0; - break; --- -2.9.2 - diff --git a/SOURCES/libvirt-conf-don-t-ignore-target-dev-blah-for-macvtap-interfaces.patch b/SOURCES/libvirt-conf-don-t-ignore-target-dev-blah-for-macvtap-interfaces.patch new file mode 100644 index 0000000..4b716d6 --- /dev/null +++ b/SOURCES/libvirt-conf-don-t-ignore-target-dev-blah-for-macvtap-interfaces.patch @@ -0,0 +1,71 @@ +From c2e748f3d928f8030e5c12b474c427086c962ad4 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Laine Stump +Date: Tue, 2 May 2017 12:33:11 -0400 +Subject: [PATCH] conf: don't ignore for macvtap + interfaces + +The parser had been clearing out *all* suggested device names for +type='direct' (aka macvtap) interfaces. All of the code implementing +macvtap allows for a user-specified device name, so we should allow +it. In the case that an interface name starts with "macvtap" or +"macvlan" though, we do still clear it out, just as we do with "vnet" +(which is the prefix used for automatically generated tap device +names), since those are the prefixes for the names we autogenerate for +macvtap and macvlan devices. + +Resolves: https://bugzilla.redhat.com/1335798 +(cherry picked from commit 9cb891141c4a5a96243c61518c4e0dbcf6a86c24) + +Signed-off-by: Jiri Denemark +--- + docs/formatdomain.html.in | 6 +++--- + src/conf/domain_conf.c | 7 ++++++- + 2 files changed, 9 insertions(+), 4 deletions(-) + +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in +index 2dc5e751a..7e55b0327 100644 +--- a/docs/formatdomain.html.in ++++ b/docs/formatdomain.html.in +@@ -5207,9 +5207,9 @@ qemu-kvm -net nic,model=? /dev/null + If no target is specified, certain hypervisors will + automatically generate a name for the created tun device. This + name can be manually specified, however the name should not +- start with either 'vnet' or 'vif', which are prefixes +- reserved by libvirt and certain hypervisors. Manually specified +- targets using these prefixes may be ignored. ++ start with either 'vnet', 'vif', 'macvtap', or 'macvlan', ++ which are prefixes reserved by libvirt and certain hypervisors. ++ Manually specified targets using these prefixes may be ignored. +

+ +

+diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 7ab5e5051..84a8a94e5 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -55,6 +55,7 @@ + #include "virtpm.h" + #include "virstring.h" + #include "virnetdev.h" ++#include "virnetdevmacvlan.h" + #include "virhostdev.h" + #include "virmdev.h" + +@@ -10016,8 +10017,12 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, + def->data.direct.linkdev = dev; + dev = NULL; + +- if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) ++ if (ifname && ++ flags & VIR_DOMAIN_DEF_PARSE_INACTIVE && ++ (STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX) || ++ STRPREFIX(ifname, VIR_NET_GENERATED_MACVTAP_PREFIX))) { + VIR_FREE(ifname); ++ } + + break; + +-- +2.12.2 + diff --git a/SOURCES/libvirt-conf-free-the-ports-array-of-a-USB-hub.patch b/SOURCES/libvirt-conf-free-the-ports-array-of-a-USB-hub.patch deleted file mode 100644 index 784373d..0000000 --- a/SOURCES/libvirt-conf-free-the-ports-array-of-a-USB-hub.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 9e0ace88fbe504e27928976d3b39182f9165aeaa Mon Sep 17 00:00:00 2001 -Message-Id: <9e0ace88fbe504e27928976d3b39182f9165aeaa@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Tue, 16 Aug 2016 12:49:57 +0200 -Subject: [PATCH] conf: free the ports array of a USB hub -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -The array needs to be freed too, not just its members. - -https://bugzilla.redhat.com/show_bug.cgi?id=1366097 -(cherry picked from commit d49f6853b36234ea0ec175dc39a5d67ba2a75123) -Signed-off-by: Ján Tomko ---- - src/conf/domain_addr.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 6567093..7f4f4d8 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1329,6 +1329,7 @@ virDomainUSBAddressHubFree(virDomainUSBAddressHubPtr hub) - - for (i = 0; i < hub->nports; i++) - virDomainUSBAddressHubFree(hub->ports[i]); -+ VIR_FREE(hub->ports); - virBitmapFree(hub->portmap); - VIR_FREE(hub); - } --- -2.9.2 - diff --git a/SOURCES/libvirt-conf-improve-error-log-when-PCI-devices-don-t-match-requested-controller.patch b/SOURCES/libvirt-conf-improve-error-log-when-PCI-devices-don-t-match-requested-controller.patch deleted file mode 100644 index 8872da1..0000000 --- a/SOURCES/libvirt-conf-improve-error-log-when-PCI-devices-don-t-match-requested-controller.patch +++ /dev/null @@ -1,106 +0,0 @@ -From fef66972e7387805fbcdf42695b9b25d0c4f4630 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Laine Stump -Date: Wed, 10 Aug 2016 11:00:11 -0400 -Subject: [PATCH] conf: improve error log when PCI devices don't match - requested controller - -The virDomainPCIAddressFlagsCompatible() error logs report that a -device required a controller that accepted standard PCI endpoint -devices, or PCI Express endpoint devices, and if hotplug was required -by the configuration but not provided by the selected controller. But -the wording of the error messages was apparently confusing (according -to the bugzilla report referenced below). On top of that, if the -device was something other than an endpoint device (e.g. a -pcie-switch-downstream-port) the error message was a complete punt - -it would just say that the flags were incorrect. - -This patch makes the messages for PCI/PCIe endpoint and hotplug -requirements more clear, and also specifically indicates what was the -device type when it is other than an endpoint device. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1363627 -(cherry picked from commit 10031fe5f218fe0acbf873a3063ce42a02fa83d9) ---- - src/conf/domain_addr.c | 58 ++++++++++++++++++++++++++++---------------------- - 1 file changed, 33 insertions(+), 25 deletions(-) - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index c3469ee..61c4074 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -118,38 +118,46 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr, - * hot-plug and this bus doesn't have it, return false. - */ - if (!(devFlags & busFlags & VIR_PCI_CONNECT_TYPES_MASK)) { -- if (reportError) { -- if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_DEVICE) { -- virReportError(errType, -- _("PCI bus is not compatible with the device " -- "at %s. Device requires a standard PCI slot, " -- "which is not provided by bus %.4x:%.2x"), -- addrStr, addr->domain, addr->bus); -- } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_DEVICE) { -- virReportError(errType, -- _("PCI bus is not compatible with the device " -- "at %s. Device requires a PCI Express slot, " -- "which is not provided by bus %.4x:%.2x"), -- addrStr, addr->domain, addr->bus); -- } else { -- /* this should never happen. If it does, there is a -- * bug in the code that sets the flag bits for devices. -- */ -- virReportError(errType, -- _("The device information for %s has no PCI " -- "connection types listed"), addrStr); -- } -+ const char *connectStr; -+ -+ if (!reportError) -+ return false; -+ -+ if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_DEVICE) { -+ connectStr = "standard PCI device"; -+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_DEVICE) { -+ connectStr = "PCI Express device"; -+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT) { -+ connectStr = "pcie-root-port"; -+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT) { -+ connectStr = "pci-switch-upstream-port"; -+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT) { -+ connectStr = "pci-switch-downstream-port"; -+ } else { -+ /* this should never happen. If it does, there is a -+ * bug in the code that sets the flag bits for devices. -+ */ -+ virReportError(errType, -+ _("The device at PCI address %s has " -+ "unrecognized connection type flags 0x%.2x"), -+ addrStr, devFlags & VIR_PCI_CONNECT_TYPES_MASK); -+ return false; - } -+ virReportError(errType, -+ _("The device at PCI address %s cannot be " -+ "plugged into the PCI controller with index='%d'. " -+ "It requires a controller that accepts a %s."), -+ addrStr, addr->bus, connectStr); - return false; - } - if ((devFlags & VIR_PCI_CONNECT_HOTPLUGGABLE) && - !(busFlags & VIR_PCI_CONNECT_HOTPLUGGABLE)) { - if (reportError) { - virReportError(errType, -- _("PCI bus is not compatible with the device " -- "at %s. Device requires hot-plug capability, " -- "which is not provided by bus %.4x:%.2x"), -- addrStr, addr->domain, addr->bus); -+ _("The device at PCI address %s requires " -+ "hotplug capability, but the PCI controller " -+ "with index='%d' doesn't support hotplug"), -+ addrStr, addr->bus); - } - return false; - } --- -2.9.2 - diff --git a/SOURCES/libvirt-conf-introduce-virDomainControllerDriverFormat.patch b/SOURCES/libvirt-conf-introduce-virDomainControllerDriverFormat.patch new file mode 100644 index 0000000..5f37f4f --- /dev/null +++ b/SOURCES/libvirt-conf-introduce-virDomainControllerDriverFormat.patch @@ -0,0 +1,104 @@ +From 8874ecd393f7098376d9c46c34f43d47a697f932 Mon Sep 17 00:00:00 2001 +Message-Id: <8874ecd393f7098376d9c46c34f43d47a697f932@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:48:55 +0200 +Subject: [PATCH] conf: introduce virDomainControllerDriverFormat +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Split out formatting the subelement of +to make adding new options easier. + +(cherry picked from commit fe262186dccfa5c5cbcfe5ab7eb95195cf3b10f5) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 55 +++++++++++++++++++++++++++++--------------------- + 1 file changed, 32 insertions(+), 23 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index e004559f9f..275145b1ec 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -21323,6 +21323,37 @@ virDomainDiskDefFormat(virBufferPtr buf, + #undef FORMAT_IOTUNE + + ++static void ++virDomainControllerDriverFormat(virBufferPtr buf, ++ virDomainControllerDefPtr def) ++{ ++ virBuffer driverBuf = VIR_BUFFER_INITIALIZER; ++ ++ if (def->queues) ++ virBufferAsprintf(&driverBuf, " queues='%u'", def->queues); ++ ++ if (def->cmd_per_lun) ++ virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun); ++ ++ if (def->max_sectors) ++ virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors); ++ ++ if (def->ioeventfd) { ++ virBufferAsprintf(&driverBuf, " ioeventfd='%s'", ++ virTristateSwitchTypeToString(def->ioeventfd)); ++ } ++ ++ if (def->iothread) ++ virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread); ++ ++ if (virBufferUse(&driverBuf)) { ++ virBufferAddLit(buf, "\n"); ++ } ++} ++ ++ + static int + virDomainControllerDefFormat(virBufferPtr buf, + virDomainControllerDefPtr def, +@@ -21332,7 +21363,6 @@ virDomainControllerDefFormat(virBufferPtr buf, + const char *model = NULL; + const char *modelName = NULL; + bool pcihole64 = false, pciModel = false, pciTarget = false; +- virBuffer driverBuf = VIR_BUFFER_INITIALIZER; + + if (!type) { + virReportError(VIR_ERR_INTERNAL_ERROR, +@@ -21437,28 +21467,7 @@ virDomainControllerDefFormat(virBufferPtr buf, + } + } + +- if (def->queues) +- virBufferAsprintf(&driverBuf, " queues='%u'", def->queues); +- +- if (def->cmd_per_lun) +- virBufferAsprintf(&driverBuf, " cmd_per_lun='%u'", def->cmd_per_lun); +- +- if (def->max_sectors) +- virBufferAsprintf(&driverBuf, " max_sectors='%u'", def->max_sectors); +- +- if (def->ioeventfd) { +- virBufferAsprintf(&driverBuf, " ioeventfd='%s'", +- virTristateSwitchTypeToString(def->ioeventfd)); +- } +- +- if (def->iothread) +- virBufferAsprintf(&driverBuf, " iothread='%u'", def->iothread); +- +- if (virBufferUse(&driverBuf)) { +- virBufferAddLit(buf, "\n"); +- } ++ virDomainControllerDriverFormat(buf, def); + + if (virDomainDeviceInfoNeedsFormat(&def->info, flags) && + virDomainDeviceInfoFormat(buf, &def->info, flags) < 0) +-- +2.13.1 + diff --git a/SOURCES/libvirt-conf-nodedev-Split-virNodeDeviceDefFormat-into-more-functions.patch b/SOURCES/libvirt-conf-nodedev-Split-virNodeDeviceDefFormat-into-more-functions.patch new file mode 100644 index 0000000..7cd3720 --- /dev/null +++ b/SOURCES/libvirt-conf-nodedev-Split-virNodeDeviceDefFormat-into-more-functions.patch @@ -0,0 +1,644 @@ +From f636c368f181c9f18ee135e8902490faf30186f9 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:48 +0200 +Subject: [PATCH] conf: nodedev: Split virNodeDeviceDefFormat into more + functions + +Make the code look cleaner by moving the capability specific bits into +separate functions. + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit bfaaaf108da087c38cc0f2890ed96730a3734ba8) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + src/conf/node_device_conf.c | 578 ++++++++++++++++++++++++-------------------- + 1 file changed, 322 insertions(+), 256 deletions(-) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index cc3fad8b9..02215f32d 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -155,6 +155,320 @@ virPCIEDeviceInfoFormat(virBufferPtr buf, + } + + ++static void ++virNodeDeviceCapSystemDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ char uuidstr[VIR_UUID_STRING_BUFLEN]; ++ ++ if (data->system.product_name) ++ virBufferEscapeString(buf, "%s\n", ++ data->system.product_name); ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ if (data->system.hardware.vendor_name) ++ virBufferEscapeString(buf, "%s\n", ++ data->system.hardware.vendor_name); ++ if (data->system.hardware.version) ++ virBufferEscapeString(buf, "%s\n", ++ data->system.hardware.version); ++ if (data->system.hardware.serial) ++ virBufferEscapeString(buf, "%s\n", ++ data->system.hardware.serial); ++ virUUIDFormat(data->system.hardware.uuid, uuidstr); ++ virBufferAsprintf(buf, "%s\n", uuidstr); ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ if (data->system.firmware.vendor_name) ++ virBufferEscapeString(buf, "%s\n", ++ data->system.firmware.vendor_name); ++ if (data->system.firmware.version) ++ virBufferEscapeString(buf, "%s\n", ++ data->system.firmware.version); ++ if (data->system.firmware.release_date) ++ virBufferEscapeString(buf, "%s\n", ++ data->system.firmware.release_date); ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++} ++ ++ ++static void ++virNodeDeviceCapPCIDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ size_t i; ++ ++ virBufferAsprintf(buf, "%d\n", ++ data->pci_dev.domain); ++ virBufferAsprintf(buf, "%d\n", data->pci_dev.bus); ++ virBufferAsprintf(buf, "%d\n", ++ data->pci_dev.slot); ++ virBufferAsprintf(buf, "%d\n", ++ data->pci_dev.function); ++ virBufferAsprintf(buf, "pci_dev.product); ++ if (data->pci_dev.product_name) ++ virBufferEscapeString(buf, ">%s\n", ++ data->pci_dev.product_name); ++ else ++ virBufferAddLit(buf, " />\n"); ++ virBufferAsprintf(buf, "pci_dev.vendor); ++ if (data->pci_dev.vendor_name) ++ virBufferEscapeString(buf, ">%s\n", ++ data->pci_dev.vendor_name); ++ else ++ virBufferAddLit(buf, " />\n"); ++ if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION) { ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ virBufferAsprintf(buf, ++ "

\n", ++ data->pci_dev.physical_function->domain, ++ data->pci_dev.physical_function->bus, ++ data->pci_dev.physical_function->slot, ++ data->pci_dev.physical_function->function); ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } ++ if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) { ++ virBufferAddLit(buf, "pci_dev.max_virtual_functions) ++ virBufferAsprintf(buf, " maxCount='%u'", ++ data->pci_dev.max_virtual_functions); ++ if (data->pci_dev.num_virtual_functions == 0) { ++ virBufferAddLit(buf, "/>\n"); ++ } else { ++ virBufferAddLit(buf, ">\n"); ++ virBufferAdjustIndent(buf, 2); ++ for (i = 0; i < data->pci_dev.num_virtual_functions; i++) { ++ virBufferAsprintf(buf, ++ "
\n", ++ data->pci_dev.virtual_functions[i]->domain, ++ data->pci_dev.virtual_functions[i]->bus, ++ data->pci_dev.virtual_functions[i]->slot, ++ data->pci_dev.virtual_functions[i]->function); ++ } ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } ++ } ++ if (data->pci_dev.hdrType) { ++ virBufferAsprintf(buf, "\n", ++ virPCIHeaderTypeToString(data->pci_dev.hdrType)); ++ } ++ if (data->pci_dev.nIommuGroupDevices) { ++ virBufferAsprintf(buf, "\n", ++ data->pci_dev.iommuGroupNumber); ++ virBufferAdjustIndent(buf, 2); ++ for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) { ++ virBufferAsprintf(buf, ++ "
\n", ++ data->pci_dev.iommuGroupDevices[i]->domain, ++ data->pci_dev.iommuGroupDevices[i]->bus, ++ data->pci_dev.iommuGroupDevices[i]->slot, ++ data->pci_dev.iommuGroupDevices[i]->function); ++ } ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } ++ if (data->pci_dev.numa_node >= 0) ++ virBufferAsprintf(buf, "\n", ++ data->pci_dev.numa_node); ++ ++ if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE) ++ virPCIEDeviceInfoFormat(buf, data->pci_dev.pci_express); ++} ++ ++ ++static void ++virNodeDeviceCapUSBDevDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ virBufferAsprintf(buf, "%d\n", data->usb_dev.bus); ++ virBufferAsprintf(buf, "%d\n", ++ data->usb_dev.device); ++ virBufferAsprintf(buf, "usb_dev.product); ++ if (data->usb_dev.product_name) ++ virBufferEscapeString(buf, ">%s\n", ++ data->usb_dev.product_name); ++ else ++ virBufferAddLit(buf, " />\n"); ++ virBufferAsprintf(buf, "usb_dev.vendor); ++ if (data->usb_dev.vendor_name) ++ virBufferEscapeString(buf, ">%s\n", ++ data->usb_dev.vendor_name); ++ else ++ virBufferAddLit(buf, " />\n"); ++} ++ ++ ++static void ++virNodeDeviceCapUSBInterfaceDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ virBufferAsprintf(buf, "%d\n", ++ data->usb_if.number); ++ virBufferAsprintf(buf, "%d\n", ++ data->usb_if._class); ++ virBufferAsprintf(buf, "%d\n", ++ data->usb_if.subclass); ++ virBufferAsprintf(buf, "%d\n", ++ data->usb_if.protocol); ++ if (data->usb_if.description) ++ virBufferEscapeString(buf, ++ "%s\n", ++ data->usb_if.description); ++} ++ ++ ++static void ++virNodeDeviceCapNetDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ size_t i; ++ ++ virBufferEscapeString(buf, "%s\n", ++ data->net.ifname); ++ if (data->net.address) ++ virBufferEscapeString(buf, "
%s
\n", ++ data->net.address); ++ virInterfaceLinkFormat(buf, &data->net.lnk); ++ if (data->net.features) { ++ for (i = 0; i < VIR_NET_DEV_FEAT_LAST; i++) { ++ if (virBitmapIsBitSet(data->net.features, i)) { ++ virBufferAsprintf(buf, "\n", ++ virNetDevFeatureTypeToString(i)); ++ } ++ } ++ } ++ if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) { ++ const char *subtyp = ++ virNodeDevNetCapTypeToString(data->net.subtype); ++ virBufferEscapeString(buf, "\n", ++ subtyp); ++ } ++} ++ ++ ++static void ++virNodeDeviceCapSCSIHostDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ virBufferAsprintf(buf, "%d\n", ++ data->scsi_host.host); ++ if (data->scsi_host.unique_id != -1) ++ virBufferAsprintf(buf, "%d\n", ++ data->scsi_host.unique_id); ++ if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ virBufferEscapeString(buf, "%s\n", ++ data->scsi_host.wwnn); ++ virBufferEscapeString(buf, "%s\n", ++ data->scsi_host.wwpn); ++ virBufferEscapeString(buf, "%s\n", ++ data->scsi_host.fabric_wwn); ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } ++ if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) { ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ virBufferAsprintf(buf, "%d\n", ++ data->scsi_host.max_vports); ++ virBufferAsprintf(buf, "%d\n", ++ data->scsi_host.vports); ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } ++} ++ ++ ++static void ++virNodeDeviceCapSCSIDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ virBufferAsprintf(buf, "%d\n", data->scsi.host); ++ virBufferAsprintf(buf, "%d\n", data->scsi.bus); ++ virBufferAsprintf(buf, "%d\n", ++ data->scsi.target); ++ virBufferAsprintf(buf, "%d\n", data->scsi.lun); ++ if (data->scsi.type) ++ virBufferEscapeString(buf, "%s\n", ++ data->scsi.type); ++} ++ ++ ++static void ++virNodeDeviceCapStorageDefFormat(virBufferPtr buf, ++ const virNodeDevCapData *data) ++{ ++ virBufferEscapeString(buf, "%s\n", ++ data->storage.block); ++ if (data->storage.bus) ++ virBufferEscapeString(buf, "%s\n", ++ data->storage.bus); ++ if (data->storage.drive_type) ++ virBufferEscapeString(buf, "%s\n", ++ data->storage.drive_type); ++ if (data->storage.model) ++ virBufferEscapeString(buf, "%s\n", ++ data->storage.model); ++ if (data->storage.vendor) ++ virBufferEscapeString(buf, "%s\n", ++ data->storage.vendor); ++ if (data->storage.serial) ++ virBufferEscapeString(buf, "%s\n", ++ data->storage.serial); ++ if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) { ++ int avl = data->storage.flags & ++ VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ virBufferAsprintf(buf, "%d" ++ "\n", avl ? 1 : 0); ++ virBufferAsprintf(buf, "%llu\n", ++ data->storage.removable_media_size); ++ if (data->storage.media_label) ++ virBufferEscapeString(buf, ++ "%s\n", ++ data->storage.media_label); ++ if (data->storage.logical_block_size > 0) ++ virBufferAsprintf(buf, "%llu" ++ "\n", ++ data->storage.logical_block_size); ++ if (data->storage.num_blocks > 0) ++ virBufferAsprintf(buf, ++ "%llu\n", ++ data->storage.num_blocks); ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } else { ++ virBufferAsprintf(buf, "%llu\n", ++ data->storage.size); ++ if (data->storage.logical_block_size > 0) ++ virBufferAsprintf(buf, "%llu" ++ "\n", ++ data->storage.logical_block_size); ++ if (data->storage.num_blocks > 0) ++ virBufferAsprintf(buf, "%llu\n", ++ data->storage.num_blocks); ++ } ++ if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE) ++ virBufferAddLit(buf, "\n"); ++} ++ ++ + char * + virNodeDeviceDefFormat(const virNodeDeviceDef *def) + { +@@ -185,7 +499,6 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) + } + + for (caps = def->caps; caps; caps = caps->next) { +- char uuidstr[VIR_UUID_STRING_BUFLEN]; + virNodeDevCapDataPtr data = &caps->data; + + virBufferAsprintf(&buf, "\n", +@@ -193,279 +506,32 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) + virBufferAdjustIndent(&buf, 2); + switch (caps->data.type) { + case VIR_NODE_DEV_CAP_SYSTEM: +- if (data->system.product_name) +- virBufferEscapeString(&buf, "%s\n", +- data->system.product_name); +- virBufferAddLit(&buf, "\n"); +- virBufferAdjustIndent(&buf, 2); +- if (data->system.hardware.vendor_name) +- virBufferEscapeString(&buf, "%s\n", +- data->system.hardware.vendor_name); +- if (data->system.hardware.version) +- virBufferEscapeString(&buf, "%s\n", +- data->system.hardware.version); +- if (data->system.hardware.serial) +- virBufferEscapeString(&buf, "%s\n", +- data->system.hardware.serial); +- virUUIDFormat(data->system.hardware.uuid, uuidstr); +- virBufferAsprintf(&buf, "%s\n", uuidstr); +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); +- +- virBufferAddLit(&buf, "\n"); +- virBufferAdjustIndent(&buf, 2); +- if (data->system.firmware.vendor_name) +- virBufferEscapeString(&buf, "%s\n", +- data->system.firmware.vendor_name); +- if (data->system.firmware.version) +- virBufferEscapeString(&buf, "%s\n", +- data->system.firmware.version); +- if (data->system.firmware.release_date) +- virBufferEscapeString(&buf, "%s\n", +- data->system.firmware.release_date); +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); ++ virNodeDeviceCapSystemDefFormat(&buf, data); + break; + case VIR_NODE_DEV_CAP_PCI_DEV: +- virBufferAsprintf(&buf, "%d\n", +- data->pci_dev.domain); +- virBufferAsprintf(&buf, "%d\n", data->pci_dev.bus); +- virBufferAsprintf(&buf, "%d\n", +- data->pci_dev.slot); +- virBufferAsprintf(&buf, "%d\n", +- data->pci_dev.function); +- virBufferAsprintf(&buf, "pci_dev.product); +- if (data->pci_dev.product_name) +- virBufferEscapeString(&buf, ">%s\n", +- data->pci_dev.product_name); +- else +- virBufferAddLit(&buf, " />\n"); +- virBufferAsprintf(&buf, "pci_dev.vendor); +- if (data->pci_dev.vendor_name) +- virBufferEscapeString(&buf, ">%s\n", +- data->pci_dev.vendor_name); +- else +- virBufferAddLit(&buf, " />\n"); +- if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION) { +- virBufferAddLit(&buf, "\n"); +- virBufferAdjustIndent(&buf, 2); +- virBufferAsprintf(&buf, +- "
\n", +- data->pci_dev.physical_function->domain, +- data->pci_dev.physical_function->bus, +- data->pci_dev.physical_function->slot, +- data->pci_dev.physical_function->function); +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); +- } +- if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) { +- virBufferAddLit(&buf, "pci_dev.max_virtual_functions) +- virBufferAsprintf(&buf, " maxCount='%u'", +- data->pci_dev.max_virtual_functions); +- if (data->pci_dev.num_virtual_functions == 0) { +- virBufferAddLit(&buf, "/>\n"); +- } else { +- virBufferAddLit(&buf, ">\n"); +- virBufferAdjustIndent(&buf, 2); +- for (i = 0; i < data->pci_dev.num_virtual_functions; i++) { +- virBufferAsprintf(&buf, +- "
\n", +- data->pci_dev.virtual_functions[i]->domain, +- data->pci_dev.virtual_functions[i]->bus, +- data->pci_dev.virtual_functions[i]->slot, +- data->pci_dev.virtual_functions[i]->function); +- } +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); +- } +- } +- if (data->pci_dev.hdrType) { +- virBufferAsprintf(&buf, "\n", +- virPCIHeaderTypeToString(data->pci_dev.hdrType)); +- } +- if (data->pci_dev.nIommuGroupDevices) { +- virBufferAsprintf(&buf, "\n", +- data->pci_dev.iommuGroupNumber); +- virBufferAdjustIndent(&buf, 2); +- for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) { +- virBufferAsprintf(&buf, +- "
\n", +- data->pci_dev.iommuGroupDevices[i]->domain, +- data->pci_dev.iommuGroupDevices[i]->bus, +- data->pci_dev.iommuGroupDevices[i]->slot, +- data->pci_dev.iommuGroupDevices[i]->function); +- } +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); +- } +- if (data->pci_dev.numa_node >= 0) +- virBufferAsprintf(&buf, "\n", +- data->pci_dev.numa_node); +- +- if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE) +- virPCIEDeviceInfoFormat(&buf, data->pci_dev.pci_express); ++ virNodeDeviceCapPCIDefFormat(&buf, data); + break; + case VIR_NODE_DEV_CAP_USB_DEV: +- virBufferAsprintf(&buf, "%d\n", data->usb_dev.bus); +- virBufferAsprintf(&buf, "%d\n", +- data->usb_dev.device); +- virBufferAsprintf(&buf, "usb_dev.product); +- if (data->usb_dev.product_name) +- virBufferEscapeString(&buf, ">%s\n", +- data->usb_dev.product_name); +- else +- virBufferAddLit(&buf, " />\n"); +- virBufferAsprintf(&buf, "usb_dev.vendor); +- if (data->usb_dev.vendor_name) +- virBufferEscapeString(&buf, ">%s\n", +- data->usb_dev.vendor_name); +- else +- virBufferAddLit(&buf, " />\n"); ++ virNodeDeviceCapUSBDevDefFormat(&buf, data); + break; + case VIR_NODE_DEV_CAP_USB_INTERFACE: +- virBufferAsprintf(&buf, "%d\n", +- data->usb_if.number); +- virBufferAsprintf(&buf, "%d\n", +- data->usb_if._class); +- virBufferAsprintf(&buf, "%d\n", +- data->usb_if.subclass); +- virBufferAsprintf(&buf, "%d\n", +- data->usb_if.protocol); +- if (data->usb_if.description) +- virBufferEscapeString(&buf, +- "%s\n", +- data->usb_if.description); ++ virNodeDeviceCapUSBInterfaceDefFormat(&buf, data); + break; + case VIR_NODE_DEV_CAP_NET: +- virBufferEscapeString(&buf, "%s\n", +- data->net.ifname); +- if (data->net.address) +- virBufferEscapeString(&buf, "
%s
\n", +- data->net.address); +- virInterfaceLinkFormat(&buf, &data->net.lnk); +- if (data->net.features) { +- for (i = 0; i < VIR_NET_DEV_FEAT_LAST; i++) { +- if (virBitmapIsBitSet(data->net.features, i)) { +- virBufferAsprintf(&buf, "\n", +- virNetDevFeatureTypeToString(i)); +- } +- } +- } +- if (data->net.subtype != VIR_NODE_DEV_CAP_NET_LAST) { +- const char *subtyp = +- virNodeDevNetCapTypeToString(data->net.subtype); +- virBufferEscapeString(&buf, "\n", +- subtyp); +- } ++ virNodeDeviceCapNetDefFormat(&buf, data); + break; + case VIR_NODE_DEV_CAP_SCSI_HOST: +- virBufferAsprintf(&buf, "%d\n", +- data->scsi_host.host); +- if (data->scsi_host.unique_id != -1) +- virBufferAsprintf(&buf, "%d\n", +- data->scsi_host.unique_id); +- if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) { +- virBufferAddLit(&buf, "\n"); +- virBufferAdjustIndent(&buf, 2); +- virBufferEscapeString(&buf, "%s\n", +- data->scsi_host.wwnn); +- virBufferEscapeString(&buf, "%s\n", +- data->scsi_host.wwpn); +- virBufferEscapeString(&buf, "%s\n", +- data->scsi_host.fabric_wwn); +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); +- } +- if (data->scsi_host.flags & VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS) { +- virBufferAddLit(&buf, "\n"); +- virBufferAdjustIndent(&buf, 2); +- virBufferAsprintf(&buf, "%d\n", +- data->scsi_host.max_vports); +- virBufferAsprintf(&buf, "%d\n", +- data->scsi_host.vports); +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); +- } +- ++ virNodeDeviceCapSCSIHostDefFormat(&buf, data); + break; +- + case VIR_NODE_DEV_CAP_SCSI_TARGET: + virBufferEscapeString(&buf, "%s\n", + data->scsi_target.name); + break; +- + case VIR_NODE_DEV_CAP_SCSI: +- virBufferAsprintf(&buf, "%d\n", data->scsi.host); +- virBufferAsprintf(&buf, "%d\n", data->scsi.bus); +- virBufferAsprintf(&buf, "%d\n", +- data->scsi.target); +- virBufferAsprintf(&buf, "%d\n", data->scsi.lun); +- if (data->scsi.type) +- virBufferEscapeString(&buf, "%s\n", +- data->scsi.type); ++ virNodeDeviceCapSCSIDefFormat(&buf, data); + break; + case VIR_NODE_DEV_CAP_STORAGE: +- virBufferEscapeString(&buf, "%s\n", +- data->storage.block); +- if (data->storage.bus) +- virBufferEscapeString(&buf, "%s\n", +- data->storage.bus); +- if (data->storage.drive_type) +- virBufferEscapeString(&buf, "%s\n", +- data->storage.drive_type); +- if (data->storage.model) +- virBufferEscapeString(&buf, "%s\n", +- data->storage.model); +- if (data->storage.vendor) +- virBufferEscapeString(&buf, "%s\n", +- data->storage.vendor); +- if (data->storage.serial) +- virBufferEscapeString(&buf, "%s\n", +- data->storage.serial); +- if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) { +- int avl = data->storage.flags & +- VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; +- virBufferAddLit(&buf, "\n"); +- virBufferAdjustIndent(&buf, 2); +- virBufferAsprintf(&buf, "%d" +- "\n", avl ? 1 : 0); +- virBufferAsprintf(&buf, "%llu\n", +- data->storage.removable_media_size); +- if (data->storage.media_label) +- virBufferEscapeString(&buf, +- "%s\n", +- data->storage.media_label); +- if (data->storage.logical_block_size > 0) +- virBufferAsprintf(&buf, "%llu" +- "\n", +- data->storage.logical_block_size); +- if (data->storage.num_blocks > 0) +- virBufferAsprintf(&buf, +- "%llu\n", +- data->storage.num_blocks); +- virBufferAdjustIndent(&buf, -2); +- virBufferAddLit(&buf, "\n"); +- } else { +- virBufferAsprintf(&buf, "%llu\n", +- data->storage.size); +- if (data->storage.logical_block_size > 0) +- virBufferAsprintf(&buf, "%llu" +- "\n", +- data->storage.logical_block_size); +- if (data->storage.num_blocks > 0) +- virBufferAsprintf(&buf, "%llu\n", +- data->storage.num_blocks); +- } +- if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE) +- virBufferAddLit(&buf, "\n"); ++ virNodeDeviceCapStorageDefFormat(&buf, data); + break; + case VIR_NODE_DEV_CAP_SCSI_GENERIC: + virBufferEscapeString(&buf, "%s\n", +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-qemu-Add-newer-shmem-models.patch b/SOURCES/libvirt-conf-qemu-Add-newer-shmem-models.patch deleted file mode 100644 index f28116c..0000000 --- a/SOURCES/libvirt-conf-qemu-Add-newer-shmem-models.patch +++ /dev/null @@ -1,273 +0,0 @@ -From 1a9572f07ac3c181166e3c67b179716d5830134c Mon Sep 17 00:00:00 2001 -Message-Id: <1a9572f07ac3c181166e3c67b179716d5830134c@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:50 +0100 -Subject: [PATCH] conf, qemu: Add newer shmem models - -The old ivshmem is deprecated in QEMU, so let's use the better -ivshmem-{plain,doorbell} variants instead. - -Signed-off-by: Martin Kletzander -(cherry picked from commit 3c06aa7b30e91920698368ceb87c49aab06e37fe) - - Conflicts: - tests/qemuxml2xmltest.c -- DO_TEST rewrite - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - docs/formatdomain.html.in | 10 +++- - docs/schemas/domaincommon.rng | 2 + - src/conf/domain_conf.c | 4 +- - src/conf/domain_conf.h | 2 + - src/qemu/qemu_command.c | 7 +++ - .../qemuxml2argv-shmem-plain-doorbell.xml | 58 +++++++++++++++++++ - .../qemuxml2xmlout-shmem-plain-doorbell.xml | 67 ++++++++++++++++++++++ - tests/qemuxml2xmltest.c | 1 + - 8 files changed, 147 insertions(+), 4 deletions(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml - create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index a39d730..e9b7bad 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -6686,10 +6686,11 @@ qemu-kvm -net nic,model=? /dev/null - ... - <devices> - <shmem name='my_shmem0'> -+ <model type='ivshmem-plain'/> - <size unit='M'>4</size> - </shmem> - <shmem name='shmem_server'> -- <model type='ivshmem'/> -+ <model type='ivshmem-doorbell'/> - <size unit='M'>2</size> - <server path='/tmp/socket-shmem'/> - <msi vectors='32' ioeventfd='on'/> -@@ -6708,8 +6709,11 @@ qemu-kvm -net nic,model=? /dev/null -
- Attribute type of the optional element model - specifies the model of the underlying device providing the -- shmem device. Currently the only supported model is -- ivshmem. -+ shmem device. The models currently supported are -+ ivshmem (supports both server and server-less shmem, but is -+ deprecated by newer QEMU in favour of the -plain and -doorbell variants), -+ ivshmem-plain (only for server-less shmem) and -+ ivshmem-doorbell (only for shmem with the server). -
-
size
-
-diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index 7d16536..6acc107 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -3557,6 +3557,8 @@ - - - ivshmem -+ ivshmem-plain -+ ivshmem-doorbell - - - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 25b1c63..514e50d 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -841,7 +841,9 @@ VIR_ENUM_IMPL(virDomainMemoryModel, VIR_DOMAIN_MEMORY_MODEL_LAST, - "", "dimm") - - VIR_ENUM_IMPL(virDomainShmemModel, VIR_DOMAIN_SHMEM_MODEL_LAST, -- "ivshmem") -+ "ivshmem", -+ "ivshmem-plain", -+ "ivshmem-doorbell") - - static virClassPtr virDomainObjClass; - static virClassPtr virDomainXMLOptionClass; -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index db74d1d..b8944cb 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -1551,6 +1551,8 @@ struct _virDomainNVRAMDef { - - typedef enum { - VIR_DOMAIN_SHMEM_MODEL_IVSHMEM, -+ VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN, -+ VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL, - - VIR_DOMAIN_SHMEM_MODEL_LAST - } virDomainShmemModel; -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index c5d29b4..e145c9f 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -8564,6 +8564,13 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, - devstr = qemuBuildShmemDevLegacyStr(def, shmem, qemuCaps); - break; - -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("%s device is not supported with this QEMU binary"), -+ virDomainShmemModelTypeToString(shmem->model)); -+ break; -+ - case VIR_DOMAIN_SHMEM_MODEL_LAST: - break; - } -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml b/tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml -new file mode 100644 -index 0000000..454437c ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-shmem-plain-doorbell.xml -@@ -0,0 +1,58 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ 128 -+ -+ -+ -+ 256 -+
-+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml -new file mode 100644 -index 0000000..ab9c69b ---- /dev/null -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem-plain-doorbell.xml -@@ -0,0 +1,67 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+
-+ -+ -+ -+ -+ -+ -+ -+
-+ -+ -+ -+ 128 -+
-+ -+ -+ -+ 256 -+
-+ -+ -+ -+ -+
-+ -+ -+ -+ -+
-+ -+ -+ -+ -+ -+
-+ -+ -+ -+ -+ -+
-+ -+ -+ -+ -+ -+
-+ -+ -+ -diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c -index 5458361..c6bf7ad 100644 ---- a/tests/qemuxml2xmltest.c -+++ b/tests/qemuxml2xmltest.c -@@ -827,6 +827,7 @@ mymain(void) - DO_TEST("tap-vhost"); - DO_TEST("tap-vhost-incorrect"); - DO_TEST("shmem"); -+ DO_TEST("shmem-plain-doorbell"); - DO_TEST("smbios"); - DO_TEST("smbios-multiple-type2"); - --- -2.10.2 - diff --git a/SOURCES/libvirt-conf-qemu-Add-support-for-shmem-model.patch b/SOURCES/libvirt-conf-qemu-Add-support-for-shmem-model.patch deleted file mode 100644 index fc6826b..0000000 --- a/SOURCES/libvirt-conf-qemu-Add-support-for-shmem-model.patch +++ /dev/null @@ -1,296 +0,0 @@ -From c07ec81488d9bba54d5ea209479c798f005faa47 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:49 +0100 -Subject: [PATCH] conf, qemu: Add support for shmem model - -Just the default one now, new ones will be added in following commits. - -Signed-off-by: Martin Kletzander -(cherry picked from commit 64530a9c667e4f875992ec0d85cffd2072b8cfd7) - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - docs/formatdomain.html.in | 8 +++++ - docs/schemas/domaincommon.rng | 9 +++++ - src/conf/domain_conf.c | 44 +++++++++++++++++------ - src/conf/domain_conf.h | 8 +++++ - src/libvirt_private.syms | 2 ++ - src/qemu/qemu_command.c | 11 +++++- - tests/qemuxml2argvdata/qemuxml2argv-shmem.xml | 2 ++ - tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml | 8 +++++ - 8 files changed, 80 insertions(+), 12 deletions(-) - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index 4970d61..a39d730 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -6689,6 +6689,7 @@ qemu-kvm -net nic,model=? /dev/null - <size unit='M'>4</size> - </shmem> - <shmem name='shmem_server'> -+ <model type='ivshmem'/> - <size unit='M'>2</size> - <server path='/tmp/socket-shmem'/> - <msi vectors='32' ioeventfd='on'/> -@@ -6703,6 +6704,13 @@ qemu-kvm -net nic,model=? /dev/null - The shmem element has one mandatory attribute, - name to identify the shared memory. -
-+
model
-+
-+ Attribute type of the optional element model -+ specifies the model of the underlying device providing the -+ shmem device. Currently the only supported model is -+ ivshmem. -+
-
size
-
- The optional size element specifies the size of the shared -diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng -index d88ff3e..7d16536 100644 ---- a/docs/schemas/domaincommon.rng -+++ b/docs/schemas/domaincommon.rng -@@ -3553,6 +3553,15 @@ - - - -+ -+ -+ -+ ivshmem -+ -+ -+ -+ -+ - - - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 25e4ba2..25b1c63 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -840,6 +840,9 @@ VIR_ENUM_IMPL(virDomainBlockJob, VIR_DOMAIN_BLOCK_JOB_TYPE_LAST, - VIR_ENUM_IMPL(virDomainMemoryModel, VIR_DOMAIN_MEMORY_MODEL_LAST, - "", "dimm") - -+VIR_ENUM_IMPL(virDomainShmemModel, VIR_DOMAIN_SHMEM_MODEL_LAST, -+ "ivshmem") -+ - static virClassPtr virDomainObjClass; - static virClassPtr virDomainXMLOptionClass; - static void virDomainObjDispose(void *obj); -@@ -12267,6 +12270,20 @@ virDomainShmemDefParseXML(xmlNodePtr node, - - ctxt->node = node; - -+ tmp = virXPathString("string(./model/@type)", ctxt); -+ if (tmp) { -+ /* If there's none, we will automatically have the first one -+ * (as default). Unfortunately this has to be done for -+ * compatibility reasons. */ -+ if ((def->model = virDomainShmemModelTypeFromString(tmp)) < 0) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("Unknown shmem model type '%s'"), tmp); -+ goto cleanup; -+ } -+ -+ VIR_FREE(tmp); -+ } -+ - if (!(def->name = virXMLPropString(node, "name"))) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("shmem element must contain 'name' attribute")); -@@ -14849,6 +14866,9 @@ virDomainShmemDefEquals(virDomainShmemDefPtr src, - if (src->size != dst->size) - return false; - -+ if (src->model != dst->model) -+ return false; -+ - if (src->server.enabled != dst->server.enabled) - return false; - -@@ -18828,6 +18848,15 @@ virDomainShmemDefCheckABIStability(virDomainShmemDefPtr src, - return false; - } - -+ if (src->model != dst->model) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -+ _("Target shared memory model '%s' does not match " -+ "source model '%s'"), -+ virDomainShmemModelTypeToString(dst->model), -+ virDomainShmemModelTypeToString(src->model)); -+ return false; -+ } -+ - if (src->size != dst->size) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Target shared memory size '%llu' does not match " -@@ -21849,20 +21878,13 @@ virDomainShmemDefFormat(virBufferPtr buf, - virDomainShmemDefPtr def, - unsigned int flags) - { -- virBufferEscapeString(buf, "name); -- -- if (!def->size && -- !def->server.enabled && -- !def->msi.enabled && -- !virDomainDeviceInfoNeedsFormat(&def->info, flags)) { -- virBufferAddLit(buf, "/>\n"); -- return 0; -- } else { -- virBufferAddLit(buf, ">\n"); -- } -+ virBufferEscapeString(buf, "\n", def->name); - - virBufferAdjustIndent(buf, 2); - -+ virBufferAsprintf(buf, "\n", -+ virDomainShmemModelTypeToString(def->model)); -+ - if (def->size) - virBufferAsprintf(buf, "%llu\n", def->size >> 20); - -diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h -index 594982e..db74d1d 100644 ---- a/src/conf/domain_conf.h -+++ b/src/conf/domain_conf.h -@@ -1549,9 +1549,16 @@ struct _virDomainNVRAMDef { - virDomainDeviceInfo info; - }; - -+typedef enum { -+ VIR_DOMAIN_SHMEM_MODEL_IVSHMEM, -+ -+ VIR_DOMAIN_SHMEM_MODEL_LAST -+} virDomainShmemModel; -+ - struct _virDomainShmemDef { - char *name; - unsigned long long size; -+ int model; /* enum virDomainShmemModel */ - struct { - bool enabled; - virDomainChrSourceDef chr; -@@ -3042,6 +3049,7 @@ VIR_ENUM_DECL(virDomainTPMBackend) - VIR_ENUM_DECL(virDomainMemoryModel) - VIR_ENUM_DECL(virDomainMemoryBackingModel) - VIR_ENUM_DECL(virDomainIOMMUModel) -+VIR_ENUM_DECL(virDomainShmemModel) - /* from libvirt.h */ - VIR_ENUM_DECL(virDomainState) - VIR_ENUM_DECL(virDomainNostateReason) -diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms -index 9b7c26c..bee5676 100644 ---- a/src/libvirt_private.syms -+++ b/src/libvirt_private.syms -@@ -460,6 +460,8 @@ virDomainShmemDefFind; - virDomainShmemDefFree; - virDomainShmemDefInsert; - virDomainShmemDefRemove; -+virDomainShmemModelTypeFromString; -+virDomainShmemModelTypeToString; - virDomainShutdownReasonTypeFromString; - virDomainShutdownReasonTypeToString; - virDomainShutoffReasonTypeFromString; -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index e668a58..c5d29b4 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -8559,7 +8559,16 @@ qemuBuildShmemCommandLine(virLogManagerPtr logManager, - return -1; - } - -- if (!(devstr = qemuBuildShmemDevLegacyStr(def, shmem, qemuCaps))) -+ switch ((virDomainShmemModel)shmem->model) { -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: -+ devstr = qemuBuildShmemDevLegacyStr(def, shmem, qemuCaps); -+ break; -+ -+ case VIR_DOMAIN_SHMEM_MODEL_LAST: -+ break; -+ } -+ -+ if (!devstr) - return -1; - virCommandAddArgList(cmd, "-device", devstr, NULL); - VIR_FREE(devstr); -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-shmem.xml b/tests/qemuxml2argvdata/qemuxml2argv-shmem.xml -index 5bc4904..b56e9e1 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-shmem.xml -+++ b/tests/qemuxml2argvdata/qemuxml2argv-shmem.xml -@@ -28,6 +28,7 @@ -
- - -+ - 512 - - -@@ -41,6 +42,7 @@ - - - -+ - 4096 - - -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml -index 1197f36..5602913 100644 ---- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-shmem.xml -@@ -22,39 +22,47 @@ - - - -+ -
- - -+ - 128 -
- - -+ - 256 -
- - -+ - 512 - -
- - -+ - 1024 - -
- - -+ - 2048 - - -
- - -+ - 4096 - - -
- - -+ - 8192 - - --- -2.10.2 - diff --git a/SOURCES/libvirt-conf-report-an-error-message-for-non-existing-USB-hubs.patch b/SOURCES/libvirt-conf-report-an-error-message-for-non-existing-USB-hubs.patch deleted file mode 100644 index 4995c06..0000000 --- a/SOURCES/libvirt-conf-report-an-error-message-for-non-existing-USB-hubs.patch +++ /dev/null @@ -1,88 +0,0 @@ -From a61eeb7afe4694defd6a6bd46f917802fd88703c Mon Sep 17 00:00:00 2001 -Message-Id: -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Tue, 16 Aug 2016 12:49:45 +0200 -Subject: [PATCH] conf: report an error message for non-existing USB hubs -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -If any of the devices referenced a USB hub that does not exist, -defining the domain would either fail with: -error: An error occurred, but the cause is unknown -(if only the last hub in the path is missing) -or crash. - -Return a proper error instead of crashing. - -https://bugzilla.redhat.com/show_bug.cgi?id=1367130 -(cherry picked from commit ef66bd5df8af93db5a77f0c1f33182139c9b63b3) -Signed-off-by: Ján Tomko ---- - src/conf/domain_addr.c | 8 ++++++++ - .../qemuxml2argv-usb-hub-nonexistent.xml | 19 +++++++++++++++++++ - tests/qemuxml2argvtest.c | 3 +++ - 3 files changed, 30 insertions(+) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-usb-hub-nonexistent.xml - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index 14baef7..6567093 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -1501,6 +1501,14 @@ virDomainUSBAddressFindPort(virDomainUSBAddressSetPtr addrs, - return NULL; - } - hub = hub->ports[portIdx]; -+ if (!hub) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("there is no hub at port %u in USB address bus: %u port: %s"), -+ info->addr.usb.port[i], -+ info->addr.usb.bus, -+ portStr); -+ return NULL; -+ } - } - - *targetIdx = info->addr.usb.port[lastIdx] - 1; -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-nonexistent.xml b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-nonexistent.xml -new file mode 100644 -index 0000000..2090319 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-usb-hub-nonexistent.xml -@@ -0,0 +1,19 @@ -+ -+ QEMUGuest1 -+ c7a5fdbd-edaf-9455-926a-d65c16db1809 -+ 219136 -+ 219136 -+ 1 -+ -+ hvm -+ -+ -+ -+ /usr/bin/qemu -+ -+ -+ -+
-+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index b86a8a1..b1ff684 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1202,6 +1202,9 @@ mymain(void) - DO_TEST_PARSE_ERROR("usb-hub-conflict", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); -+ DO_TEST_PARSE_ERROR("usb-hub-nonexistent", -+ QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, -+ QEMU_CAPS_NODEFCONFIG); - DO_TEST("usb-port-missing", - QEMU_CAPS_CHARDEV, QEMU_CAPS_USB_HUB, - QEMU_CAPS_NODEFCONFIG); --- -2.9.2 - diff --git a/SOURCES/libvirt-conf-restrict-expander-buses-to-connect-only-to-a-root-bus.patch b/SOURCES/libvirt-conf-restrict-expander-buses-to-connect-only-to-a-root-bus.patch deleted file mode 100644 index acfbef4..0000000 --- a/SOURCES/libvirt-conf-restrict-expander-buses-to-connect-only-to-a-root-bus.patch +++ /dev/null @@ -1,233 +0,0 @@ -From 646a880d28b878dc45decb1b6d6238bf42ad1006 Mon Sep 17 00:00:00 2001 -Message-Id: <646a880d28b878dc45decb1b6d6238bf42ad1006@dist-git> -From: Laine Stump -Date: Wed, 10 Aug 2016 11:00:14 -0400 -Subject: [PATCH] conf: restrict expander buses to connect only to a root bus - -More misunderstanding/mistaken assumptions on my part - I had thought -that a pci-expander-bus could be plugged into any legacy PCI slot, and -that pcie-expander-bus could be plugged into any PCIe slot. This isn't -correct - they can both be plugged ontly into their respective root -buses. This patch adds that restriction. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1358712 -(cherry picked from commit a220f43a65cca6c6f2ca268cdbbf8f997b2e2b13) ---- - src/conf/domain_addr.c | 32 +++++++++------ - src/conf/domain_addr.h | 6 ++- - .../qemuxml2argv-pci-expander-bus-bad-bus.xml | 26 ++++++++++++ - .../qemuxml2argv-pcie-expander-bus-bad-bus.xml | 48 ++++++++++++++++++++++ - tests/qemuxml2argvtest.c | 8 ++++ - 5 files changed, 107 insertions(+), 13 deletions(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index ea641a5..14baef7 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -51,20 +51,17 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model) - return 0; - - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: -- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: -- /* pci-bridge and pci-expander-bus are treated like a standard -- * PCI endpoint device, because they can plug into any -- * standard PCI slot. -+ /* pci-bridge is treated like a standard -+ * PCI endpoint device, because it can plug into any -+ * standard PCI slot (it just can't be hotplugged). - */ - return VIR_PCI_CONNECT_TYPE_PCI_DEVICE; - -+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: -+ return VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS; -+ - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: -- /* pcie-expander-bus is treated like a standard PCIe endpoint -- * device (the part of pcie-expander-bus that is plugged in -- * isn't the expander bus itself, but a companion device used -- * for setting it up). -- */ -- return VIR_PCI_CONNECT_TYPE_PCIE_DEVICE; -+ return VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS; - - case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - return VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE; -@@ -137,6 +134,10 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr, - connectStr = "pci-switch-downstream-port"; - } else if (devFlags & VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE) { - connectStr = "dmi-to-pci-bridge"; -+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS) { -+ connectStr = "pci-expander-bus"; -+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS) { -+ connectStr = "pcie-expander-bus"; - } else { - /* this should never happen. If it does, there is a - * bug in the code that sets the flag bits for devices. -@@ -243,9 +244,15 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, - * bus. - */ - switch (model) { -- case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: - case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: - bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE | -+ VIR_PCI_CONNECT_TYPE_PCI_DEVICE | -+ VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS); -+ bus->minSlot = 1; -+ bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST; -+ break; -+ case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: -+ bus->flags = (VIR_PCI_CONNECT_HOTPLUGGABLE | - VIR_PCI_CONNECT_TYPE_PCI_DEVICE); - bus->minSlot = 1; - bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST; -@@ -265,7 +272,8 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, - */ - bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE | - VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | -- VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE); -+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE | -+ VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS); - bus->minSlot = 1; - bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST; - break; -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index 2d55c46..da19311 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -41,6 +41,8 @@ typedef enum { - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 4, - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 5, - VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 6, -+ VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS = 1 << 7, -+ VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS = 1 << 8, - } virDomainPCIConnectFlags; - - /* a combination of all bits that describe the type of connections -@@ -51,7 +53,9 @@ typedef enum { - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT | \ - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT | \ - VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | \ -- VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE) -+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE | \ -+ VIR_PCI_CONNECT_TYPE_PCI_EXPANDER_BUS | \ -+ VIR_PCI_CONNECT_TYPE_PCIE_EXPANDER_BUS) - - /* combination of all bits that could be used to connect a normal - * endpoint device (i.e. excluding the connection possible between an -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml -new file mode 100644 -index 0000000..85c1115 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-pci-expander-bus-bad-bus.xml -@@ -0,0 +1,26 @@ -+ -+ expander-test -+ 3ec6cbe1-b5a2-4515-b800-31a61855df41 -+ 219100 -+ 219100 -+ 16 -+ -+ hvm -+ -+ -+ /usr/bin/qemu-system-x86_64 -+ -+ -+
-+ -+ -+ -+ -+ -+
-+ -+ -+ -+ -+ -+ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml -new file mode 100644 -index 0000000..0305f35 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-pcie-expander-bus-bad-bus.xml -@@ -0,0 +1,48 @@ -+ -+ pcie-expander-bus-test -+ 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 -+ 2097152 -+ 2097152 -+ 16 -+ -+ hvm -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/libexec/qemu-kvm -+ -+ -+ -+
-+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ 1 -+ -+
-+ -+ -+
-+ -+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index c7c0ff2..b86a8a1 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1730,6 +1730,9 @@ mymain(void) - DO_TEST_PARSE_ERROR("pci-expander-bus-bad-machine", - QEMU_CAPS_DEVICE_PCI_BRIDGE, - QEMU_CAPS_DEVICE_PXB); -+ DO_TEST_PARSE_ERROR("pci-expander-bus-bad-bus", -+ QEMU_CAPS_DEVICE_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_PXB); - - DO_TEST("pcie-expander-bus", - QEMU_CAPS_DEVICE_PCI_BRIDGE, -@@ -1745,6 +1748,11 @@ mymain(void) - QEMU_CAPS_DEVICE_X3130_UPSTREAM, - QEMU_CAPS_DEVICE_XIO3130_DOWNSTREAM, - QEMU_CAPS_DEVICE_PXB_PCIE); -+ DO_TEST_PARSE_ERROR("pcie-expander-bus-bad-bus", -+ QEMU_CAPS_DEVICE_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_IOH3420, -+ QEMU_CAPS_DEVICE_PXB_PCIE); - - DO_TEST("hostdev-scsi-lsi", - QEMU_CAPS_VIRTIO_SCSI, QEMU_CAPS_SCSI_LSI, --- -2.9.2 - diff --git a/SOURCES/libvirt-conf-restrict-where-dmi-to-pci-bridge-can-be-connected.patch b/SOURCES/libvirt-conf-restrict-where-dmi-to-pci-bridge-can-be-connected.patch deleted file mode 100644 index f58b26d..0000000 --- a/SOURCES/libvirt-conf-restrict-where-dmi-to-pci-bridge-can-be-connected.patch +++ /dev/null @@ -1,212 +0,0 @@ -From 4e81f870fc9f235df004fe33f668217f34c5d210 Mon Sep 17 00:00:00 2001 -Message-Id: <4e81f870fc9f235df004fe33f668217f34c5d210@dist-git> -From: Laine Stump -Date: Wed, 10 Aug 2016 11:00:13 -0400 -Subject: [PATCH] conf: restrict where dmi-to-pci-bridge can be connected - -libvirt had allowed a dmi-to-pci-bridge to be plugged in anywhere a -normal PCIe endpoint can be connected, but this is wrong - it will -only work if it's plugged into pcie-root (the PCIe root complex) or a -pcie-expander-bus (the qemu device pxb-pcie). This patch adjusts the -connection flags accordingly. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1363648 -(cherry picked from commit b70e3d0123fcb6e22e99d1b272239e03a84262cb) ---- - src/conf/domain_addr.c | 26 ++++++++++----- - src/conf/domain_addr.h | 4 ++- - .../qemuxml2argv-q35-dmi-bad-address1.xml | 31 +++++++++++++++++ - .../qemuxml2argv-q35-dmi-bad-address2.xml | 39 ++++++++++++++++++++++ - tests/qemuxml2argvtest.c | 8 +++++ - 5 files changed, 98 insertions(+), 10 deletions(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address1.xml - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address2.xml - -diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c -index c22329d..ea641a5 100644 ---- a/src/conf/domain_addr.c -+++ b/src/conf/domain_addr.c -@@ -58,15 +58,17 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model) - */ - return VIR_PCI_CONNECT_TYPE_PCI_DEVICE; - -- case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: -- /* dmi-to-pci-bridge and pcie-expander-bus are treated like -- * PCIe devices (the part of pcie-expander-bus that is plugged -- * in isn't the expander bus itself, but a companion device -- * used for setting it up). -+ /* pcie-expander-bus is treated like a standard PCIe endpoint -+ * device (the part of pcie-expander-bus that is plugged in -+ * isn't the expander bus itself, but a companion device used -+ * for setting it up). - */ - return VIR_PCI_CONNECT_TYPE_PCIE_DEVICE; - -+ case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: -+ return VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE; -+ - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: - return VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT; - -@@ -133,6 +135,8 @@ virDomainPCIAddressFlagsCompatible(virPCIDeviceAddressPtr addr, - connectStr = "pci-switch-upstream-port"; - } else if (devFlags & VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT) { - connectStr = "pci-switch-downstream-port"; -+ } else if (devFlags & VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE) { -+ connectStr = "dmi-to-pci-bridge"; - } else { - /* this should never happen. If it does, there is a - * bug in the code that sets the flag bits for devices. -@@ -259,8 +263,9 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, - * user config *and* the particular device being attached also - * allows it. - */ -- bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE -- | VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT); -+ bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_DEVICE | -+ VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | -+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE); - bus->minSlot = 1; - bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST; - break; -@@ -291,8 +296,11 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPtr bus, - bus->maxSlot = VIR_PCI_ADDRESS_SLOT_LAST; - break; - case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: -- /* single slot, no hotplug, only accepts pcie-root-port */ -- bus->flags = VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT; -+ /* single slot, no hotplug, only accepts pcie-root-port or -+ * dmi-to-pci-bridge -+ */ -+ bus->flags = (VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | -+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE); - bus->minSlot = 0; - bus->maxSlot = 0; - break; -diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h -index ce94981..2d55c46 100644 ---- a/src/conf/domain_addr.h -+++ b/src/conf/domain_addr.h -@@ -40,6 +40,7 @@ typedef enum { - VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT = 1 << 3, - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT = 1 << 4, - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT = 1 << 5, -+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE = 1 << 6, - } virDomainPCIConnectFlags; - - /* a combination of all bits that describe the type of connections -@@ -49,7 +50,8 @@ typedef enum { - (VIR_PCI_CONNECT_TYPE_PCI_DEVICE | VIR_PCI_CONNECT_TYPE_PCIE_DEVICE | \ - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_UPSTREAM_PORT | \ - VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT | \ -- VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT) -+ VIR_PCI_CONNECT_TYPE_PCIE_ROOT_PORT | \ -+ VIR_PCI_CONNECT_TYPE_DMI_TO_PCI_BRIDGE) - - /* combination of all bits that could be used to connect a normal - * endpoint device (i.e. excluding the connection possible between an -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address1.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address1.xml -new file mode 100644 -index 0000000..e23c874 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address1.xml -@@ -0,0 +1,31 @@ -+ -+ q35-test -+ 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 -+ 2097152 -+ 2097152 -+ 2 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/libexec/qemu-kvm -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
-+ -+ -+ -+ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address2.xml b/tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address2.xml -new file mode 100644 -index 0000000..c3c1b6a ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-q35-dmi-bad-address2.xml -@@ -0,0 +1,39 @@ -+ -+ q35-test -+ 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 -+ 2097152 -+ 2097152 -+ 2 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/libexec/qemu-kvm -+ -+ -+ -+
-+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+
-+ -+ -+ -+ -+ -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index 927728e..c7c0ff2 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -1631,6 +1631,14 @@ mymain(void) - QEMU_CAPS_PCI_MULTIFUNCTION, QEMU_CAPS_ICH9_USB_EHCI1, - QEMU_CAPS_DEVICE_VIDEO_PRIMARY, - QEMU_CAPS_VGA_QXL, QEMU_CAPS_DEVICE_QXL); -+ DO_TEST_PARSE_ERROR("q35-dmi-bad-address1", -+ QEMU_CAPS_DEVICE_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_IOH3420); -+ DO_TEST_PARSE_ERROR("q35-dmi-bad-address2", -+ QEMU_CAPS_DEVICE_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, -+ QEMU_CAPS_DEVICE_IOH3420); - DO_TEST("q35-pm-disable", - QEMU_CAPS_DEVICE_PCI_BRIDGE, - QEMU_CAPS_DEVICE_DMI_TO_PCI_BRIDGE, QEMU_CAPS_ICH9_AHCI, --- -2.9.2 - diff --git a/SOURCES/libvirt-conf-split-out-virDomainIOMMUDefCheckABIStability.patch b/SOURCES/libvirt-conf-split-out-virDomainIOMMUDefCheckABIStability.patch new file mode 100644 index 0000000..9d33757 --- /dev/null +++ b/SOURCES/libvirt-conf-split-out-virDomainIOMMUDefCheckABIStability.patch @@ -0,0 +1,64 @@ +From 244b42c385fc611380bfb2532905a63ce4380254 Mon Sep 17 00:00:00 2001 +Message-Id: <244b42c385fc611380bfb2532905a63ce4380254@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Tue, 16 May 2017 10:44:58 +0200 +Subject: [PATCH] conf: split out virDomainIOMMUDefCheckABIStability +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +(cherry picked from commit 3a276c6524026b661ed7bee4539fc5387b963611) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1427005 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 24 +++++++++++++++++------- + 1 file changed, 17 insertions(+), 7 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index e77b542f3..7bf480f2a 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -19810,6 +19810,22 @@ virDomainMemoryDefCheckABIStability(virDomainMemoryDefPtr src, + + + static bool ++virDomainIOMMUDefCheckABIStability(virDomainIOMMUDefPtr src, ++ virDomainIOMMUDefPtr dst) ++{ ++ if (src->model != dst->model) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("Target domain IOMMU device model '%s' " ++ "does not match source '%s'"), ++ virDomainIOMMUModelTypeToString(dst->model), ++ virDomainIOMMUModelTypeToString(src->model)); ++ return false; ++ } ++ return true; ++} ++ ++ ++static bool + virDomainDefVcpuCheckAbiStability(virDomainDefPtr src, + virDomainDefPtr dst) + { +@@ -20275,14 +20291,8 @@ virDomainDefCheckABIStabilityFlags(virDomainDefPtr src, + } + + if (src->iommu && +- src->iommu->model != dst->iommu->model) { +- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, +- _("Target domain IOMMU device model '%s' " +- "does not match source '%s'"), +- virDomainIOMMUModelTypeToString(dst->iommu->model), +- virDomainIOMMUModelTypeToString(src->iommu->model)); ++ !virDomainIOMMUDefCheckABIStability(src->iommu, dst->iommu)) + goto error; +- } + + /* Coverity is not very happy with this - all dead_error_condition */ + #if !STATIC_ANALYSIS +-- +2.13.0 + diff --git a/SOURCES/libvirt-conf-use-a-leading-space-in-virDomainVirtioNetDriverFormat.patch b/SOURCES/libvirt-conf-use-a-leading-space-in-virDomainVirtioNetDriverFormat.patch new file mode 100644 index 0000000..fe28da8 --- /dev/null +++ b/SOURCES/libvirt-conf-use-a-leading-space-in-virDomainVirtioNetDriverFormat.patch @@ -0,0 +1,77 @@ +From 5238dd8211d06fc8c7003bb608e41bb2a4653dec Mon Sep 17 00:00:00 2001 +Message-Id: <5238dd8211d06fc8c7003bb608e41bb2a4653dec@dist-git> +From: =?UTF-8?q?J=C3=A1n=20Tomko?= +Date: Fri, 9 Jun 2017 12:48:59 +0200 +Subject: [PATCH] conf: use a leading space in virDomainVirtioNetDriverFormat +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Instead of formatting a space after every option. + +Reviewed-by: Pavel Hrdina +(cherry picked from commit d1feb4773d41b928dc1079dfc19d17b5a0e5957b) +Signed-off-by: Ján Tomko + +https://bugzilla.redhat.com/show_bug.cgi?id=1283251 +Signed-off-by: Jiri Denemark +--- + src/conf/domain_conf.c | 18 ++++++++---------- + 1 file changed, 8 insertions(+), 10 deletions(-) + +diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c +index 701a6d2136..4652e1c72b 100644 +--- a/src/conf/domain_conf.c ++++ b/src/conf/domain_conf.c +@@ -22053,29 +22053,27 @@ virDomainVirtioNetDriverFormat(char **outstr, + { + virBuffer buf = VIR_BUFFER_INITIALIZER; + if (def->driver.virtio.name) { +- virBufferAsprintf(&buf, "name='%s' ", ++ virBufferAsprintf(&buf, " name='%s'", + virDomainNetBackendTypeToString(def->driver.virtio.name)); + } + if (def->driver.virtio.txmode) { +- virBufferAsprintf(&buf, "txmode='%s' ", ++ virBufferAsprintf(&buf, " txmode='%s'", + virDomainNetVirtioTxModeTypeToString(def->driver.virtio.txmode)); + } + if (def->driver.virtio.ioeventfd) { +- virBufferAsprintf(&buf, "ioeventfd='%s' ", ++ virBufferAsprintf(&buf, " ioeventfd='%s'", + virTristateSwitchTypeToString(def->driver.virtio.ioeventfd)); + } + if (def->driver.virtio.event_idx) { +- virBufferAsprintf(&buf, "event_idx='%s' ", ++ virBufferAsprintf(&buf, " event_idx='%s'", + virTristateSwitchTypeToString(def->driver.virtio.event_idx)); + } + if (def->driver.virtio.queues) +- virBufferAsprintf(&buf, "queues='%u' ", def->driver.virtio.queues); ++ virBufferAsprintf(&buf, " queues='%u'", def->driver.virtio.queues); + if (def->driver.virtio.rx_queue_size) +- virBufferAsprintf(&buf, "rx_queue_size='%u' ", ++ virBufferAsprintf(&buf, " rx_queue_size='%u'", + def->driver.virtio.rx_queue_size); + +- virBufferTrim(&buf, " ", -1); +- + if (virBufferCheckError(&buf) < 0) + return -1; + +@@ -22323,10 +22321,10 @@ virDomainNetDefFormat(virBufferPtr buf, + + if (!gueststr && !hoststr) { + if (str) +- virBufferAsprintf(buf, "\n", str); ++ virBufferAsprintf(buf, "\n", str); + } else { + if (str) +- virBufferAsprintf(buf, "\n", str); ++ virBufferAsprintf(buf, "\n", str); + else + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); +-- +2.13.1 + diff --git a/SOURCES/libvirt-cpu-Drop-feature-filtering-from-virCPUUpdate.patch b/SOURCES/libvirt-cpu-Drop-feature-filtering-from-virCPUUpdate.patch new file mode 100644 index 0000000..239d248 --- /dev/null +++ b/SOURCES/libvirt-cpu-Drop-feature-filtering-from-virCPUUpdate.patch @@ -0,0 +1,58 @@ +From 2642333131bda397dc4b00fd945efdd34e2aa314 Mon Sep 17 00:00:00 2001 +Message-Id: <2642333131bda397dc4b00fd945efdd34e2aa314@dist-git> +From: Jiri Denemark +Date: Wed, 29 Mar 2017 15:00:21 +0200 +Subject: [PATCH] cpu: Drop feature filtering from virCPUUpdate + +Because of the changes done in the previous commit, @host is already a +migratable CPU and there's no need to do any additional filtering. + +Signed-off-by: Jiri Denemark +(cherry picked from commit 232d87c7dd081d126a079fb45178e0be096cc680) + +https://bugzilla.redhat.com/show_bug.cgi?id=1444421 + +Signed-off-by: Jiri Denemark +--- + src/cpu/cpu_x86.c | 9 +++------ + 1 file changed, 3 insertions(+), 6 deletions(-) + +diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c +index a771b251e..53359ff9b 100644 +--- a/src/cpu/cpu_x86.c ++++ b/src/cpu/cpu_x86.c +@@ -2549,8 +2549,7 @@ x86Baseline(virCPUDefPtr *cpus, + + static int + x86UpdateHostModel(virCPUDefPtr guest, +- const virCPUDef *host, +- virCPUx86MapPtr map) ++ const virCPUDef *host) + { + virCPUDefPtr updated = NULL; + size_t i; +@@ -2559,11 +2558,9 @@ x86UpdateHostModel(virCPUDefPtr guest, + if (!(updated = virCPUDefCopyWithoutModel(host))) + goto cleanup; + +- /* Remove non-migratable features by default */ + updated->type = VIR_CPU_TYPE_GUEST; + updated->mode = VIR_CPU_MODE_CUSTOM; +- if (virCPUDefCopyModelFilter(updated, host, true, +- x86FeatureIsMigratable, map) < 0) ++ if (virCPUDefCopyModel(updated, host, true) < 0) + goto cleanup; + + if (guest->vendor_id) { +@@ -2627,7 +2624,7 @@ virCPUx86Update(virCPUDefPtr guest, + + if (guest->mode == VIR_CPU_MODE_HOST_MODEL || + guest->match == VIR_CPU_MATCH_MINIMUM) +- ret = x86UpdateHostModel(guest, host, map); ++ ret = x86UpdateHostModel(guest, host); + else + ret = 0; + +-- +2.12.2 + diff --git a/SOURCES/libvirt-cpu-Introduce-virCPUCopyMigratable.patch b/SOURCES/libvirt-cpu-Introduce-virCPUCopyMigratable.patch new file mode 100644 index 0000000..382224f --- /dev/null +++ b/SOURCES/libvirt-cpu-Introduce-virCPUCopyMigratable.patch @@ -0,0 +1,154 @@ +From 57b2e02a1c4cf52f3ea1ec3af469dd4e44402595 Mon Sep 17 00:00:00 2001 +Message-Id: <57b2e02a1c4cf52f3ea1ec3af469dd4e44402595@dist-git> +From: Jiri Denemark +Date: Wed, 29 Mar 2017 14:45:44 +0200 +Subject: [PATCH] cpu: Introduce virCPUCopyMigratable + +This new internal API makes a copy of virCPUDef while removing all +features which would block migration. It uses cpu_map.xml as a database +of such features, which should only be used as a fallback when we cannot +get the data from a hypervisor. The main goal of this API is to decouple +this filtering from virCPUUpdate so that the hypervisor driver can +filter the features according to the hypervisor. + +Signed-off-by: Jiri Denemark +(cherry picked from commit 05e91c79f19e0be96526098d58a3498dac3f8529) + +https://bugzilla.redhat.com/show_bug.cgi?id=1444421 + +Signed-off-by: Jiri Denemark +--- + src/cpu/cpu.c | 31 +++++++++++++++++++++++++++++++ + src/cpu/cpu.h | 8 ++++++++ + src/cpu/cpu_x86.c | 25 +++++++++++++++++++++++++ + src/libvirt_private.syms | 1 + + 4 files changed, 65 insertions(+) + +diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c +index 93647a2ed..8a407ac18 100644 +--- a/src/cpu/cpu.c ++++ b/src/cpu/cpu.c +@@ -1130,3 +1130,34 @@ virCPUExpandFeatures(virArch arch, + VIR_DEBUG("nfeatures=%zu", cpu->nfeatures); + return 0; + } ++ ++ ++/** ++ * virCPUCopyMigratable: ++ * ++ * @arch: CPU architecture ++ * @cpu: CPU definition to be copied ++ * ++ * Makes a copy of @cpu with all features which would block migration removed. ++ * If this doesn't make sense for a given architecture, the function returns a ++ * plain copy of @cpu (i.e., a copy with no features removed). ++ * ++ * Returns the copy of the CPU or NULL on error. ++ */ ++virCPUDefPtr ++virCPUCopyMigratable(virArch arch, ++ virCPUDefPtr cpu) ++{ ++ struct cpuArchDriver *driver; ++ ++ VIR_DEBUG("arch=%s, cpu=%p, model=%s", ++ virArchToString(arch), cpu, NULLSTR(cpu->model)); ++ ++ if (!(driver = cpuGetSubDriver(arch))) ++ return NULL; ++ ++ if (driver->copyMigratable) ++ return driver->copyMigratable(cpu); ++ else ++ return virCPUDefCopy(cpu); ++} +diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h +index 8c238ad55..352445c40 100644 +--- a/src/cpu/cpu.h ++++ b/src/cpu/cpu.h +@@ -118,6 +118,9 @@ typedef int + typedef int + (*virCPUArchExpandFeatures)(virCPUDefPtr cpu); + ++typedef virCPUDefPtr ++(*virCPUArchCopyMigratable)(virCPUDefPtr cpu); ++ + struct cpuArchDriver { + const char *name; + const virArch *arch; +@@ -138,6 +141,7 @@ struct cpuArchDriver { + virCPUArchTranslate translate; + virCPUArchConvertLegacy convertLegacy; + virCPUArchExpandFeatures expandFeatures; ++ virCPUArchCopyMigratable copyMigratable; + }; + + +@@ -254,6 +258,10 @@ int + virCPUExpandFeatures(virArch arch, + virCPUDefPtr cpu); + ++virCPUDefPtr ++virCPUCopyMigratable(virArch arch, ++ virCPUDefPtr cpu); ++ + /* virCPUDataFormat and virCPUDataParse are implemented for unit tests only and + * have no real-life usage + */ +diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c +index 48648a7f4..a771b251e 100644 +--- a/src/cpu/cpu_x86.c ++++ b/src/cpu/cpu_x86.c +@@ -2903,6 +2903,30 @@ virCPUx86ExpandFeatures(virCPUDefPtr cpu) + } + + ++static virCPUDefPtr ++virCPUx86CopyMigratable(virCPUDefPtr cpu) ++{ ++ virCPUDefPtr copy; ++ virCPUx86MapPtr map; ++ ++ if (!(map = virCPUx86GetMap())) ++ return NULL; ++ ++ if (!(copy = virCPUDefCopyWithoutModel(cpu))) ++ return NULL; ++ ++ if (virCPUDefCopyModelFilter(copy, cpu, false, ++ x86FeatureIsMigratable, map) < 0) ++ goto error; ++ ++ return copy; ++ ++ error: ++ virCPUDefFree(copy); ++ return NULL; ++} ++ ++ + int + virCPUx86DataAddCPUID(virCPUDataPtr cpuData, + const virCPUx86CPUID *cpuid) +@@ -2978,4 +3002,5 @@ struct cpuArchDriver cpuDriverX86 = { + .getModels = virCPUx86GetModels, + .translate = virCPUx86Translate, + .expandFeatures = virCPUx86ExpandFeatures, ++ .copyMigratable = virCPUx86CopyMigratable, + }; +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 9a334311d..cc78c5975 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -1018,6 +1018,7 @@ virCPUCheckFeature; + virCPUCompare; + virCPUCompareXML; + virCPUConvertLegacy; ++virCPUCopyMigratable; + virCPUDataCheckFeature; + virCPUDataFormat; + virCPUDataFree; +-- +2.12.2 + diff --git a/SOURCES/libvirt-cpu-Introduce-virCPUGetHostIsSupported.patch b/SOURCES/libvirt-cpu-Introduce-virCPUGetHostIsSupported.patch new file mode 100644 index 0000000..87757a9 --- /dev/null +++ b/SOURCES/libvirt-cpu-Introduce-virCPUGetHostIsSupported.patch @@ -0,0 +1,83 @@ +From 401cbf50f18234b0631b4b0e01b9e403137fee95 Mon Sep 17 00:00:00 2001 +Message-Id: <401cbf50f18234b0631b4b0e01b9e403137fee95@dist-git> +From: Jiri Denemark +Date: Tue, 11 Apr 2017 20:45:07 +0200 +Subject: [PATCH] cpu: Introduce virCPUGetHostIsSupported + +Sometimes we want to call virCPUGetHost only when it is implemented for +a given architecture to avoid logging expected and possibly misleading +errors. The new virCPUGetHostIsSupported API may be used to guard such +calls to virCPUGetHost. + +Signed-off-by: Jiri Denemark +(cherry picked from commit bf1a881715c905c67f7d38dcd5bd6c2afbff1f9b) + +https://bugzilla.redhat.com/show_bug.cgi?id=1444421 + +Signed-off-by: Jiri Denemark +--- + src/cpu/cpu.c | 20 ++++++++++++++++++++ + src/cpu/cpu.h | 3 +++ + src/libvirt_private.syms | 1 + + 3 files changed, 24 insertions(+) + +diff --git a/src/cpu/cpu.c b/src/cpu/cpu.c +index 8a407ac18..702b14dbb 100644 +--- a/src/cpu/cpu.c ++++ b/src/cpu/cpu.c +@@ -358,6 +358,26 @@ virCPUDataFree(virCPUDataPtr data) + + + /** ++ * virCPUGetHostIsSupported: ++ * ++ * @arch: CPU architecture ++ * ++ * Check whether virCPUGetHost is supported for @arch. ++ * ++ * Returns true if virCPUGetHost is supported, false otherwise. ++ */ ++bool ++virCPUGetHostIsSupported(virArch arch) ++{ ++ struct cpuArchDriver *driver; ++ ++ VIR_DEBUG("arch=%s", virArchToString(arch)); ++ ++ return (driver = cpuGetSubDriver(arch)) && driver->getHost; ++} ++ ++ ++/** + * virCPUGetHost: + * + * @arch: CPU architecture +diff --git a/src/cpu/cpu.h b/src/cpu/cpu.h +index 352445c40..c6ca111e9 100644 +--- a/src/cpu/cpu.h ++++ b/src/cpu/cpu.h +@@ -183,6 +183,9 @@ virCPUDataNew(virArch arch); + void + virCPUDataFree(virCPUDataPtr data); + ++bool ++virCPUGetHostIsSupported(virArch arch); ++ + virCPUDefPtr + virCPUGetHost(virArch arch, + virCPUType type, +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index cc78c5975..d802e7598 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -1026,6 +1026,7 @@ virCPUDataNew; + virCPUDataParse; + virCPUExpandFeatures; + virCPUGetHost; ++virCPUGetHostIsSupported; + virCPUGetModels; + virCPUProbeHost; + virCPUTranslate; +-- +2.12.2 + diff --git a/SOURCES/libvirt-cpu_x86-Fix-host-model-CPUs-on-hosts-with-CMT.patch b/SOURCES/libvirt-cpu_x86-Fix-host-model-CPUs-on-hosts-with-CMT.patch deleted file mode 100644 index 47e5623..0000000 --- a/SOURCES/libvirt-cpu_x86-Fix-host-model-CPUs-on-hosts-with-CMT.patch +++ /dev/null @@ -1,68 +0,0 @@ -From cdc937aeef0901ba76e3b51029b8ae3cef58c9de Mon Sep 17 00:00:00 2001 -Message-Id: -From: Jiri Denemark -Date: Tue, 9 Aug 2016 15:15:20 +0200 -Subject: [PATCH] cpu_x86: Fix host-model CPUs on hosts with CMT - -Since the introduction of CMT features (commit v1.3.5-461-gf294b83) -starting a domain with host-model CPU on a host which supports CMT fails -because QEMU complains about unknown 'cmt' feature: - - qemu-system-x86_64: CPU feature cmt not found - -https://bugzilla.redhat.com/show_bug.cgi?id=1355857 - -Signed-off-by: Jiri Denemark -(cherry picked from commit 300f668c665f1ec0f834917fe8a58b5991322441) - -RHEL changes: - - since commit v2.0.0-8-g0c8ec3b libvirt in RHEL always passes - +rtm,+hle options to Haswell and Broadwell CPUs - -https://bugzilla.redhat.com/show_bug.cgi?id=1365500 - -Signed-off-by: Jiri Denemark ---- - src/cpu/cpu_x86.c | 8 ++++++-- - tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args | 2 +- - 2 files changed, 7 insertions(+), 3 deletions(-) - -diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c -index 24ef76b..670b02e 100644 ---- a/src/cpu/cpu_x86.c -+++ b/src/cpu/cpu_x86.c -@@ -2542,12 +2542,16 @@ x86UpdateHostModel(virCPUDefPtr guest, - goto cleanup; - } - -- /* Remove non-migratable features by default -+ /* Remove non-migratable features and CMT related features which QEMU -+ * knows nothing about. - * Note: this only works as long as no CPU model contains non-migratable - * features directly */ - i = 0; - while (i < guest->nfeatures) { -- if (x86FeatureIsMigratable(guest->features[i].name, map)) { -+ if (x86FeatureIsMigratable(guest->features[i].name, map) && -+ STRNEQ(guest->features[i].name, "cmt") && -+ STRNEQ(guest->features[i].name, "mbm_total") && -+ STRNEQ(guest->features[i].name, "mbm_local")) { - i++; - } else { - VIR_FREE(guest->features[i].name); -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args -index 884ca57..b7fdf4b 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-host-model-cmt.args -@@ -9,7 +9,7 @@ QEMU_AUDIO_DRV=none \ - -S \ - -M pc \ - -cpu Haswell,+vme,+ds,+acpi,+ss,+ht,+tm,+pbe,+dtes64,+monitor,+ds_cpl,+vmx,\ --+smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+cmt,+pdpe1gb,+abm,+rtm,+hle \ -++smx,+est,+tm2,+xtpr,+pdcm,+osxsave,+f16c,+rdrand,+pdpe1gb,+abm,+rtm,+hle \ - -m 214 \ - -smp 6 \ - -uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ --- -2.9.2 - diff --git a/SOURCES/libvirt-cpu_x86-Fix-minimum-match-custom-CPUs-on-hosts-with-CMT.patch b/SOURCES/libvirt-cpu_x86-Fix-minimum-match-custom-CPUs-on-hosts-with-CMT.patch deleted file mode 100644 index 828aa00..0000000 --- a/SOURCES/libvirt-cpu_x86-Fix-minimum-match-custom-CPUs-on-hosts-with-CMT.patch +++ /dev/null @@ -1,84 +0,0 @@ -From 1433f648ba50ee55b5c4ee2170fbe9433795d7c8 Mon Sep 17 00:00:00 2001 -Message-Id: <1433f648ba50ee55b5c4ee2170fbe9433795d7c8@dist-git> -From: Jiri Denemark -Date: Wed, 7 Sep 2016 15:16:57 +0200 -Subject: [PATCH] cpu_x86: Fix minimum match custom CPUs on hosts with CMT - -Since the introduction of CMT features (commit v1.3.5-461-gf294b83) -starting a domain with custom CPU and match='minimum' on a host which -supports CMT fails because QEMU complains about unknown 'cmt' feature. - -"cpu_x86: Fix host-model CPUs on hosts with CMT" commit fixed similar -issue for host-model CPUs. - -This patch is a RHEL-only hack because upstream fixes this by unifying -the code for these two types of CPUs, but the upstream solution is -invasive and cannot be easily backported. - -https://bugzilla.redhat.com/show_bug.cgi?id=1365500 - -Signed-off-by: Jiri Denemark ---- - src/cpu/cpu_x86.c | 18 +++++++++++++----- - 1 file changed, 13 insertions(+), 5 deletions(-) - -diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c -index 670b02e..d7c58cf 100644 ---- a/src/cpu/cpu_x86.c -+++ b/src/cpu/cpu_x86.c -@@ -456,7 +456,8 @@ static int - x86DataToCPUFeatures(virCPUDefPtr cpu, - int policy, - virCPUx86Data *data, -- virCPUx86MapPtr map) -+ virCPUx86MapPtr map, -+ bool filter) - { - size_t i; - -@@ -464,6 +465,13 @@ x86DataToCPUFeatures(virCPUDefPtr cpu, - virCPUx86FeaturePtr feature = map->features[i]; - if (x86DataIsSubset(data, &feature->data)) { - x86DataSubtract(data, &feature->data); -+ -+ if (filter && -+ (STREQ(feature->name, "cmt") || -+ STREQ(feature->name, "mbm_total") || -+ STREQ(feature->name, "mbm_local"))) -+ continue; -+ - if (virCPUDefAddFeature(cpu, feature->name, policy) < 0) - return -1; - } -@@ -595,8 +603,8 @@ x86DataToCPU(const virCPUx86Data *data, - /* because feature policy is ignored for host CPU */ - cpu->type = VIR_CPU_TYPE_GUEST; - -- if (x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_REQUIRE, ©, map) || -- x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_DISABLE, &modelData, map)) -+ if (x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_REQUIRE, ©, map, false) || -+ x86DataToCPUFeatures(cpu, VIR_CPU_FEATURE_DISABLE, &modelData, map, false)) - goto error; - - cleanup: -@@ -1835,7 +1843,7 @@ x86Decode(virCPUDefPtr cpu, - - x86DataSubtract(©, &features); - if (x86DataToCPUFeatures(cpuModel, VIR_CPU_FEATURE_REQUIRE, -- ©, map) < 0) -+ ©, map, false) < 0) - goto cleanup; - } - -@@ -2503,7 +2511,7 @@ x86UpdateCustom(virCPUDefPtr guest, - guest->match = VIR_CPU_MATCH_EXACT; - if (x86ModelSubtractCPU(host_model, guest, map) || - x86DataToCPUFeatures(guest, VIR_CPU_FEATURE_REQUIRE, -- &host_model->data, map)) -+ &host_model->data, map, true)) - goto cleanup; - } - --- -2.10.0 - diff --git a/SOURCES/libvirt-cpu_x86-Introduce-x86FeatureIsMigratable.patch b/SOURCES/libvirt-cpu_x86-Introduce-x86FeatureIsMigratable.patch deleted file mode 100644 index 6be35a7..0000000 --- a/SOURCES/libvirt-cpu_x86-Introduce-x86FeatureIsMigratable.patch +++ /dev/null @@ -1,81 +0,0 @@ -From 780500abda14bb71111592254d01c973d16be320 Mon Sep 17 00:00:00 2001 -Message-Id: <780500abda14bb71111592254d01c973d16be320@dist-git> -From: Jiri Denemark -Date: Tue, 28 Jun 2016 10:51:41 +0200 -Subject: [PATCH] cpu_x86: Introduce x86FeatureIsMigratable - -Signed-off-by: Jiri Denemark -(cherry picked from commit dbb14bb0f1316d92c89541fca816c91dce0dc8fb) - -https://bugzilla.redhat.com/show_bug.cgi?id=1365500 - -Signed-off-by: Jiri Denemark ---- - src/cpu/cpu_x86.c | 37 +++++++++++++++++++++++-------------- - 1 file changed, 23 insertions(+), 14 deletions(-) - -diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c -index d9646eb..7bb2bb6 100644 ---- a/src/cpu/cpu_x86.c -+++ b/src/cpu/cpu_x86.c -@@ -767,6 +767,22 @@ x86FeatureFindInternal(const char *name) - } - - -+static bool -+x86FeatureIsMigratable(const char *name, -+ void *cpu_map) -+{ -+ virCPUx86MapPtr map = cpu_map; -+ size_t i; -+ -+ for (i = 0; i < map->nblockers; i++) { -+ if (STREQ(name, map->migrate_blockers[i]->name)) -+ return false; -+ } -+ -+ return true; -+} -+ -+ - static char * - x86FeatureNames(virCPUx86MapPtr map, - const char *separator, -@@ -1801,14 +1817,10 @@ x86Decode(virCPUDefPtr cpu, - * features directly */ - if (flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) { - for (i = 0; i < cpuModel->nfeatures; i++) { -- size_t j; -- for (j = 0; j < map->nblockers; j++) { -- if (STREQ(map->migrate_blockers[j]->name, -- cpuModel->features[i].name)) { -- VIR_FREE(cpuModel->features[i].name); -- VIR_DELETE_ELEMENT_INPLACE(cpuModel->features, i, -- cpuModel->nfeatures); -- } -+ if (!x86FeatureIsMigratable(cpuModel->features[i].name, map)) { -+ VIR_FREE(cpuModel->features[i].name); -+ VIR_DELETE_ELEMENT_INPLACE(cpuModel->features, i, -+ cpuModel->nfeatures); - } - } - } -@@ -2531,12 +2543,9 @@ x86UpdateHostModel(virCPUDefPtr guest, - * Note: this only works as long as no CPU model contains non-migratable - * features directly */ - for (i = 0; i < guest->nfeatures; i++) { -- size_t j; -- for (j = 0; j < map->nblockers; j++) { -- if (STREQ(map->migrate_blockers[j]->name, guest->features[i].name)) { -- VIR_FREE(guest->features[i].name); -- VIR_DELETE_ELEMENT_INPLACE(guest->features, i, guest->nfeatures); -- } -+ if (!x86FeatureIsMigratable(guest->features[i].name, map)) { -+ VIR_FREE(guest->features[i].name); -+ VIR_DELETE_ELEMENT_INPLACE(guest->features, i, guest->nfeatures); - } - } - for (i = 0; !passthrough && i < oldguest->nfeatures; i++) { --- -2.9.2 - diff --git a/SOURCES/libvirt-cpu_x86-Properly-drop-non-migratable-features.patch b/SOURCES/libvirt-cpu_x86-Properly-drop-non-migratable-features.patch deleted file mode 100644 index 6885e95..0000000 --- a/SOURCES/libvirt-cpu_x86-Properly-drop-non-migratable-features.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 50244446129418acbd9efd72ebbd5c166d62dc62 Mon Sep 17 00:00:00 2001 -Message-Id: <50244446129418acbd9efd72ebbd5c166d62dc62@dist-git> -From: Jiri Denemark -Date: Tue, 28 Jun 2016 11:12:41 +0200 -Subject: [PATCH] cpu_x86: Properly drop non-migratable features - -By removing a non-migratable feature in a for loop we would fail to drop -every second non-migratable feature if the features array contained -several of them in a row. - -Signed-off-by: Jiri Denemark -(cherry picked from commit 1ac897a15da11d1bfca2642bce3b0beaad32bcf1) - -https://bugzilla.redhat.com/show_bug.cgi?id=1365500 - -Signed-off-by: Jiri Denemark ---- - src/cpu/cpu_x86.c | 14 ++++++++++---- - 1 file changed, 10 insertions(+), 4 deletions(-) - -diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c -index 7bb2bb6..24ef76b 100644 ---- a/src/cpu/cpu_x86.c -+++ b/src/cpu/cpu_x86.c -@@ -1816,8 +1816,11 @@ x86Decode(virCPUDefPtr cpu, - * Note: this only works as long as no CPU model contains non-migratable - * features directly */ - if (flags & VIR_CONNECT_BASELINE_CPU_MIGRATABLE) { -- for (i = 0; i < cpuModel->nfeatures; i++) { -- if (!x86FeatureIsMigratable(cpuModel->features[i].name, map)) { -+ i = 0; -+ while (i < cpuModel->nfeatures) { -+ if (x86FeatureIsMigratable(cpuModel->features[i].name, map)) { -+ i++; -+ } else { - VIR_FREE(cpuModel->features[i].name); - VIR_DELETE_ELEMENT_INPLACE(cpuModel->features, i, - cpuModel->nfeatures); -@@ -2542,8 +2545,11 @@ x86UpdateHostModel(virCPUDefPtr guest, - /* Remove non-migratable features by default - * Note: this only works as long as no CPU model contains non-migratable - * features directly */ -- for (i = 0; i < guest->nfeatures; i++) { -- if (!x86FeatureIsMigratable(guest->features[i].name, map)) { -+ i = 0; -+ while (i < guest->nfeatures) { -+ if (x86FeatureIsMigratable(guest->features[i].name, map)) { -+ i++; -+ } else { - VIR_FREE(guest->features[i].name); - VIR_DELETE_ELEMENT_INPLACE(guest->features, i, guest->nfeatures); - } --- -2.9.2 - diff --git a/SOURCES/libvirt-daemon-Don-t-initialize-SASL-context-if-not-necessary.patch b/SOURCES/libvirt-daemon-Don-t-initialize-SASL-context-if-not-necessary.patch new file mode 100644 index 0000000..159fca0 --- /dev/null +++ b/SOURCES/libvirt-daemon-Don-t-initialize-SASL-context-if-not-necessary.patch @@ -0,0 +1,43 @@ +From 8c9296cbe21657aadbc4bff88eabd617168349f6 Mon Sep 17 00:00:00 2001 +Message-Id: <8c9296cbe21657aadbc4bff88eabd617168349f6@dist-git> +From: Peter Krempa +Date: Fri, 2 Jun 2017 15:07:59 +0200 +Subject: [PATCH] daemon: Don't initialize SASL context if not necessary + +SASL context would be initialized even if the corresponding TCP or TLS +sockets are not enabled. + +fe772f24a68 attempted to fix the symptom by commenting out the settings, +but that did not fix the root cause. 3c647ee4bbb later reverted those +changes so that the more secure algorithm is used. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1450095 +(cherry picked from commit ed914284ba74afb7dd16dcb623073bb1a1d5cd21) + +Signed-off-by: Jiri Denemark +--- + daemon/libvirtd.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c +index 891238bcbe..bac4bc1b65 100644 +--- a/daemon/libvirtd.c ++++ b/daemon/libvirtd.c +@@ -613,11 +613,11 @@ daemonSetupNetworking(virNetServerPtr srv, + + #if WITH_SASL + if (config->auth_unix_rw == REMOTE_AUTH_SASL || +- config->auth_unix_ro == REMOTE_AUTH_SASL || ++ (sock_path_ro && config->auth_unix_ro == REMOTE_AUTH_SASL) || + # if WITH_GNUTLS +- config->auth_tls == REMOTE_AUTH_SASL || ++ (ipsock && config->listen_tls && config->auth_tls == REMOTE_AUTH_SASL) || + # endif +- config->auth_tcp == REMOTE_AUTH_SASL) { ++ (ipsock && config->listen_tcp && config->auth_tcp == REMOTE_AUTH_SASL)) { + saslCtxt = virNetSASLContextNewServer( + (const char *const*)config->sasl_allowed_username_list); + if (!saslCtxt) +-- +2.13.1 + diff --git a/SOURCES/libvirt-daemon-sasl-Don-t-forget-to-save-SASL-username-to-client-s-identity.patch b/SOURCES/libvirt-daemon-sasl-Don-t-forget-to-save-SASL-username-to-client-s-identity.patch deleted file mode 100644 index e151021..0000000 --- a/SOURCES/libvirt-daemon-sasl-Don-t-forget-to-save-SASL-username-to-client-s-identity.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 4046e4e0a1d031f37b7e614e64ee0eeb968ecaeb Mon Sep 17 00:00:00 2001 -Message-Id: <4046e4e0a1d031f37b7e614e64ee0eeb968ecaeb@dist-git> -From: Erik Skultety -Date: Tue, 2 Aug 2016 08:47:45 +0200 -Subject: [PATCH] daemon: sasl: Don't forget to save SASL username to client's - identity - -Once the SASL authentication process has successfully passed, we should also -save the SASL username used to client's identity, so that when a client like -virt-admin tries to obtain it, the server will actually format the username to -the response data. - -Signed-off-by: Erik Skultety -(cherry picked from commit 5289e21f31be226fd22bc3b512b8cc233fa24046) - -https://bugzilla.redhat.com/show_bug.cgi?id=1361948 -Signed-off-by: Erik Skultety ---- - daemon/remote.c | 6 ++++++ - 1 file changed, 6 insertions(+) - -diff --git a/daemon/remote.c b/daemon/remote.c -index 4aa43c2..6991a7e 100644 ---- a/daemon/remote.c -+++ b/daemon/remote.c -@@ -3116,6 +3116,7 @@ static int - remoteSASLFinish(virNetServerPtr server, - virNetServerClientPtr client) - { -+ virIdentityPtr clnt_identity = NULL; - const char *identity; - struct daemonClientPrivate *priv = virNetServerClientGetPrivateData(client); - int ssf; -@@ -3138,9 +3139,13 @@ remoteSASLFinish(virNetServerPtr server, - if (!virNetSASLContextCheckIdentity(saslCtxt, identity)) - return -2; - -+ if (!(clnt_identity = virNetServerClientGetIdentity(client))) -+ goto error; -+ - virNetServerClientSetAuth(client, 0); - virNetServerTrackCompletedAuth(server); - virNetServerClientSetSASLSession(client, priv->sasl); -+ virIdentitySetSASLUserName(clnt_identity, identity); - - VIR_DEBUG("Authentication successful %d", virNetServerClientGetFD(client)); - -@@ -3148,6 +3153,7 @@ remoteSASLFinish(virNetServerPtr server, - "client=%p auth=%d identity=%s", - client, REMOTE_AUTH_SASL, identity); - -+ virObjectUnref(clnt_identity); - virObjectUnref(priv->sasl); - priv->sasl = NULL; - --- -2.9.2 - diff --git a/SOURCES/libvirt-disk-Force-usage-of-parted-when-checking-disk-format-for-bsd.patch b/SOURCES/libvirt-disk-Force-usage-of-parted-when-checking-disk-format-for-bsd.patch new file mode 100644 index 0000000..e867cc5 --- /dev/null +++ b/SOURCES/libvirt-disk-Force-usage-of-parted-when-checking-disk-format-for-bsd.patch @@ -0,0 +1,43 @@ +From 911438df6c652e377f80712c67da90aed91444b7 Mon Sep 17 00:00:00 2001 +Message-Id: <911438df6c652e377f80712c67da90aed91444b7@dist-git> +From: John Ferlan +Date: Wed, 26 Apr 2017 08:41:09 -0400 +Subject: [PATCH] disk: Force usage of parted when checking disk format for + "bsd" + +https://bugzilla.redhat.com/show_bug.cgi?id=1439132 + +Add "bsd" to the list of format types to not checked during blkid +processing even though it supposedly knows the format - for some +(now unknown) reason it's returning partition table not found. So +let's just let PARTED handle "bsd" too. + +Signed-off-by: John Ferlan +(cherry picked from commit 98f424d5038b362d1b62549930d0b9253106bdca) +Signed-off-by: Jiri Denemark +--- + src/storage/storage_util.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c +index 7a458b828..adec9ab6f 100644 +--- a/src/storage/storage_util.c ++++ b/src/storage/storage_util.c +@@ -3002,10 +3002,12 @@ virStorageBackendBLKIDFindPart(blkid_probe probe, + + /* A blkid_known_pttype on "dvh" and "pc98" returns a failure; + * however, the blkid_do_probe for "dvh" returns "sgi" and +- * for "pc98" it returns "dos". So since those will cause problems ++ * for "pc98" it returns "dos". Although "bsd" is recognized, ++ * it seems that the parted created partition table is not being ++ * properly recogized. Since each of these will cause problems + * with startup comparison, let's just treat them as UNKNOWN causing + * the caller to fallback to using PARTED */ +- if (STREQ(format, "dvh") || STREQ(format, "pc98")) ++ if (STREQ(format, "dvh") || STREQ(format, "pc98") || STREQ(format, "bsd")) + return VIR_STORAGE_BLKID_PROBE_UNKNOWN; + + /* Make sure we're doing a partitions probe from the start */ +-- +2.12.2 + diff --git a/SOURCES/libvirt-disk-Resolve-issues-with-disk-partition-build-start-checks.patch b/SOURCES/libvirt-disk-Resolve-issues-with-disk-partition-build-start-checks.patch new file mode 100644 index 0000000..77b111d --- /dev/null +++ b/SOURCES/libvirt-disk-Resolve-issues-with-disk-partition-build-start-checks.patch @@ -0,0 +1,40 @@ +From 5c1a822cfa7993b1f55f90b75b66c86787a063d1 Mon Sep 17 00:00:00 2001 +Message-Id: <5c1a822cfa7993b1f55f90b75b66c86787a063d1@dist-git> +From: John Ferlan +Date: Wed, 26 Apr 2017 08:41:08 -0400 +Subject: [PATCH] disk: Resolve issues with disk partition build/start checks + +https://bugzilla.redhat.com/show_bug.cgi?id=1439132 + +Commit id 'a48c674fb' added a check for format types "dvh" and "pc98" +to use the parted print processing instead of using blkid processing +in order to validate the label on the disk was what is expected for +disk pool startup. However, commit id 'a4cb4a74f' really messed things +up by missing an else condition causing PARTEDFindLabel to always +return DIFFERENT. + +Signed-off-by: John Ferlan +(cherry picked from commit f2a123203105b4fe010aea866e87f8bcf5f31193) +Signed-off-by: Jiri Denemark +--- + src/storage/storage_util.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c +index 0ceaab6b9..7a458b828 100644 +--- a/src/storage/storage_util.c ++++ b/src/storage/storage_util.c +@@ -3213,8 +3213,8 @@ virStorageBackendPARTEDFindLabel(const char *device, + /* Does the on disk match what the pool desired? */ + if (STREQ(start, format)) + ret = VIR_STORAGE_PARTED_MATCH; +- +- ret = VIR_STORAGE_PARTED_DIFFERENT; ++ else ++ ret = VIR_STORAGE_PARTED_DIFFERENT; + + cleanup: + virCommandFree(cmd); +-- +2.12.2 + diff --git a/SOURCES/libvirt-disk-Use-virStorageBackendZeroPartitionTable.patch b/SOURCES/libvirt-disk-Use-virStorageBackendZeroPartitionTable.patch new file mode 100644 index 0000000..705de4d --- /dev/null +++ b/SOURCES/libvirt-disk-Use-virStorageBackendZeroPartitionTable.patch @@ -0,0 +1,56 @@ +From 9aeaadcf7d7f33cc5208bcbc788676f27691843a Mon Sep 17 00:00:00 2001 +Message-Id: <9aeaadcf7d7f33cc5208bcbc788676f27691843a@dist-git> +From: John Ferlan +Date: Wed, 26 Apr 2017 08:41:14 -0400 +Subject: [PATCH] disk: Use virStorageBackendZeroPartitionTable + +https://bugzilla.redhat.com/show_bug.cgi?id=1439132 + +During 'matrix' testing of all possible combinations I found that if +device is formated with "gpt" first, then an attempt is made to format +using "mac", a startup will fail. + +Deeper analysis by Peter Krempa indicates that the "mac" table fits +into the first block on the disk. Since the GPT disklabel is stored +at LBA address 1 it is not overwritten at all. Thus it's apparent that +the (blkid) detection tool then prefers GPT over a older disklabel. + +The GPT disklabel has also a secondary copy at the last LBA of the disk. + +So, follow the same logic as the logical pool in clearing a 1MB swath +at the beginning and end of the device to avoid potential issues with +larger sector sizes for the device. + +Also fixed a minor formatting nit in virStorageBackendDeviceIsEmpty call. + +(cherry picked from commit 3c4f2e3fb725054921f855a229afc7daca7119ae) +Signed-off-by: John Ferlan +Signed-off-by: Jiri Denemark +--- + src/storage/storage_backend_disk.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c +index 39371f2d9..e8f67bb00 100644 +--- a/src/storage/storage_backend_disk.c ++++ b/src/storage/storage_backend_disk.c +@@ -491,11 +491,15 @@ virStorageBackendDiskBuildPool(virConnectPtr conn ATTRIBUTE_UNUSED, + ok_to_mklabel = true; + } else { + if (virStorageBackendDeviceIsEmpty(pool->def->source.devices[0].path, +- fmt, true)) ++ fmt, true)) + ok_to_mklabel = true; + } + + if (ok_to_mklabel) { ++ if (virStorageBackendZeroPartitionTable(pool->def->source.devices[0].path, ++ 1024 * 1024) < 0) ++ goto error; ++ + /* eg parted /dev/sda mklabel --script msdos */ + if (format == VIR_STORAGE_POOL_DISK_UNKNOWN) + format = pool->def->source.format = VIR_STORAGE_POOL_DISK_DOS; +-- +2.12.2 + diff --git a/SOURCES/libvirt-doc-clarify-documentation-for-vcpu-order.patch b/SOURCES/libvirt-doc-clarify-documentation-for-vcpu-order.patch deleted file mode 100644 index 00bae1a..0000000 --- a/SOURCES/libvirt-doc-clarify-documentation-for-vcpu-order.patch +++ /dev/null @@ -1,41 +0,0 @@ -From c7e89383dcdf9bfb6a51c0b22cacbf54bd44995d Mon Sep 17 00:00:00 2001 -Message-Id: -From: Peter Krempa -Date: Fri, 26 Aug 2016 15:45:25 -0400 -Subject: [PATCH] doc: clarify documentation for vcpu order - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Make it clear that vcpu order is valid for online vcpus only and state -that it has to be specified for all vcpus or not provided at all. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1370043 -(cherry picked from commit 54147fd9be31838904f6f2251510da91a1bd0ca7) ---- - docs/formatdomain.html.in | 7 ++++--- - 1 file changed, 4 insertions(+), 3 deletions(-) - -diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in -index a838bff..c080bdf 100644 ---- a/docs/formatdomain.html.in -+++ b/docs/formatdomain.html.in -@@ -564,11 +564,12 @@ - all disabled vcpus must be hotpluggable. Valid values are - yes and no. - -- order allows to specify the order to add the vcpus. For -- hypervisors/platforms that require to insert multiple vcpus at once -+ order allows to specify the order to add the online vcpus. -+ For hypervisors/platforms that require to insert multiple vcpus at once - the order may be be duplicated accross all vcpus that need to be - enabled at once. Specifying order is not necessary, vcpus are then -- added in an arbitrary order. -+ added in an arbitrary order. If order info is used, it must be used for -+ all online vcpus. - - Note that hypervisors may create hotpluggable vcpus differently from - boot vcpus thus special initialization may be necessary. --- -2.10.0 - diff --git a/SOURCES/libvirt-docs-Distribute-subsite.xsl.patch b/SOURCES/libvirt-docs-Distribute-subsite.xsl.patch deleted file mode 100644 index cfd0439..0000000 --- a/SOURCES/libvirt-docs-Distribute-subsite.xsl.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 3070510fac4e5462ede573b2127514483edaef36 Mon Sep 17 00:00:00 2001 -Message-Id: <3070510fac4e5462ede573b2127514483edaef36@dist-git> -From: Michal Privoznik -Date: Mon, 8 Aug 2016 13:08:50 +0200 -Subject: [PATCH] docs: Distribute subsite.xsl - -https://bugzilla.redhat.com/show_bug.cgi?id=1365004 - -So, I've ran into very interesting problem lately. When doing the -following, I've encountered an error: - - libvirt.git $ make dist && tar -xJf libvirt-2.2.0.tar.xz && \ - cd libvirt-2.2.0 && ./configure && \ - rm docs/formatdomain.html && make -C docs - - make: Entering directory 'docs' - make: *** No rule to make target 'formatdomain.html', needed by 'web'. Stop. - make: Leaving directory 'docs' - -I had no idea what was going on, so I've nailed down the commit -that "broke it" via running git-bisect. It was this one: -7659bd9221b9dd1cdf. But that shed no more light until I realized -that the commit might actually just exposed a problem we had. And -guess what - I've nailed it down. Of course we are not -distributing subsite.xsl that's why make prints error message. -Very misleading one I must say. - -Signed-off-by: Michal Privoznik -(cherry picked from commit e396de03f31d87f3e81c7820739951d50367ddb8) -Signed-off-by: Michal Privoznik ---- - docs/Makefile.am | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/docs/Makefile.am b/docs/Makefile.am -index 206ef3b..14aad83 100644 ---- a/docs/Makefile.am -+++ b/docs/Makefile.am -@@ -152,7 +152,7 @@ schema_DATA = $(wildcard $(srcdir)/schemas/*.rng) - - EXTRA_DIST= \ - apibuild.py genaclperms.pl \ -- site.xsl newapi.xsl news.xsl page.xsl \ -+ site.xsl subsite.xsl newapi.xsl news.xsl page.xsl \ - hacking1.xsl hacking2.xsl wrapstring.xsl \ - $(dot_html) $(dot_html_in) $(gif) $(apihtml) $(apipng) \ - $(devhelphtml) $(devhelppng) $(devhelpcss) $(devhelpxsl) \ --- -2.9.2 - diff --git a/SOURCES/libvirt-docs-Document-the-mediated-devices-within-the-nodedev-driver.patch b/SOURCES/libvirt-docs-Document-the-mediated-devices-within-the-nodedev-driver.patch new file mode 100644 index 0000000..fa10ab2 --- /dev/null +++ b/SOURCES/libvirt-docs-Document-the-mediated-devices-within-the-nodedev-driver.patch @@ -0,0 +1,231 @@ +From 9a202d80f7b60fcf6caf059570bfd2d0b0cbe8a4 Mon Sep 17 00:00:00 2001 +Message-Id: <9a202d80f7b60fcf6caf059570bfd2d0b0cbe8a4@dist-git> +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:55 +0200 +Subject: [PATCH] docs: Document the mediated devices within the nodedev driver + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit a0a0b3cf71cbee1df40dd0fdebd7bb6a84682f09) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + docs/drvnodedev.html.in | 168 +++++++++++++++++++++++++++++++++++++++++++++++- + tools/virsh.pod | 7 +- + 2 files changed, 171 insertions(+), 4 deletions(-) + +diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in +index 0a3870343..26c52dd0d 100644 +--- a/docs/drvnodedev.html.in ++++ b/docs/drvnodedev.html.in +@@ -9,7 +9,7 @@ + (historically also referred to as node devices) like USB, PCI, SCSI, and + network devices. This also includes various virtualization capabilities + which the aforementioned devices provide for utilization, for example +- SR-IOV, NPIV, DRM, etc. ++ SR-IOV, NPIV, MDEV, DRM, etc. +

+ +

+@@ -75,6 +75,7 @@ + storage (Since 1.0.4), + scsi_generic (Since 1.0.7), + drm (Since 3.1.0), and ++ mdev (Since 3.4.0). + This element can be nested in which case it further specifies a + device's capability. Refer to specific device types to see more values + for the type attribute which are exclusive. +@@ -185,5 +186,170 @@ + ... + <device>

+ ++

MDEV capability

++

++ A PCI device capable of creating mediated devices will include a nested ++ capability mdev_types which enumerates all supported mdev ++ types on the physical device, along with the type attributes available ++ through sysfs: ++

++ ++
++
type
++
++ This element describes a mediated device type which acts as an ++ abstract template defining a resource allocation for instances of this ++ device type. The element has one attribute id which holds ++ an official vendor-supplied identifier for the type. ++ Since 3.4.0 ++
++ ++
name
++
++ The name element holds a vendor-supplied code name for ++ the given mediated device type. This is an optional element. ++ Since 3.4.0 ++
++ ++
deviceAPI
++
++ The value of this element describes how an instance of the given type ++ will be presented to the guest by the VFIO framework. ++ Since 3.4.0 ++
++ ++
availableInstances
++
++ This element reports the current state of resource allocation. In other ++ words, how many instances of the given type can still be successfully ++ created on the physical device. ++ Since 3.4.0 ++
++
++ ++

++ For a more info about mediated devices, refer to the ++ paragraph below. ++

++ ++
++<device>
++...
++  <driver>
++    <name>nvidia</name>
++  </driver>
++  <capability type='pci'>
++...
++    <capability type='mdev_types'>
++      <type id='nvidia-11'>
++        <name>GRID M60-0B</name>
++        <deviceAPI>vfio-pci</deviceAPI>
++        <availableInstances>16</availableInstances>
++      </type>
++      <!-- Here would come the rest of the available mdev types -->
++    </capability>
++...
++  </capability>
++</device>
++ ++

Mediated devices (MDEVs)

++

++ Mediated devices (Since 3.2.0) are software ++ devices defining resource allocation on the backing physical device which ++ in turn allows the parent physical device's resources to be divided into ++ several mediated devices, thus sharing the physical device's performance ++ among multiple guests. Unlike SR-IOV however, where a PCIe device appears ++ as multiple separate PCIe devices on the host's PCI bus, mediated devices ++ only appear on the mdev virtual bus. Therefore, no detach/reattach ++ procedure from/to the host driver procedure is involved even though ++ mediated devices are used in a direct device assignment manner. ++

++ ++

++ The following sub-elements and attributes are exposed within the ++ capability element: ++

++ ++
++
type
++
++ This element describes a mediated device type which acts as an ++ abstract template defining a resource allocation for instances of this ++ device type. The element has one attribute id which holds ++ an official vendor-supplied identifier for the type. ++ Since 3.4.0 ++
++ ++
iommuGroup
++
++ This element supports a single attribute number which holds ++ the IOMMU group number the mediated device belongs to. ++ Since 3.4.0 ++
++
++ ++

Example of a mediated device

++
++<device>
++  <name>mdev_4b20d080_1b54_4048_85b3_a6a62d165c01</name>
++  <path>/sys/devices/pci0000:00/0000:00:02.0/4b20d080-1b54-4048-85b3-a6a62d165c01</path>
++  <parent>pci_0000_06_00_0</parent>
++  <driver>
++    <name>vfio_mdev</name>
++  </driver>
++  <capability type='mdev'>
++    <type id='nvidia-11'/>
++    <iommuGroup number='12'/>
++  <capability/>
++<device/>
++ ++

++ The support of mediated device's framework in libvirt's node device driver ++ covers the following features: ++

++ ++
    ++
  • ++ list available mediated devices on the host ++ (Since 3.4.0) ++
  • ++
  • ++ display device details ++ (Since 3.4.0) ++
  • ++
++ ++

++ Because mediated devices are instantiated from vendor specific templates, ++ simply called 'types', information describing these types is contained ++ within the parent device's capabilities ++ (see the example in PCI host devices). ++

++ ++

++ To see the supported mediated device types on a specific physical device ++ use the following: ++

++ ++
++$ ls /sys/class/mdev_bus/<device>/mdev_supported_types
++ ++

++ To manually instantiate a mediated device, use one of the following as a ++ reference: ++

++ ++
++$ uuidgen > /sys/class/mdev_bus/<device>/mdev_supported_types/<type>/create
++...
++$ echo <UUID> > /sys/class/mdev_bus/<device>/mdev_supported_types/<type>/create
++ ++

++ Manual removal of a mediated device is then performed as follows: ++

++ ++
++$ echo 1 > /sys/bus/mdev/devices/<uuid>/remove
++ + + +diff --git a/tools/virsh.pod b/tools/virsh.pod +index 0dd1fc7b2..11bacefa9 100644 +--- a/tools/virsh.pod ++++ b/tools/virsh.pod +@@ -3155,10 +3155,11 @@ for HBA). + + List all of the devices available on the node that are known by libvirt. + I is used to filter the list by capability types, the types must be +-separated by comma, e.g. --cap pci,scsi, valid capability types include ++separated by comma, e.g. --cap pci,scsi. Valid capability types include + 'system', 'pci', 'usb_device', 'usb', 'net', 'scsi_host', 'scsi_target', +-'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm'.If I<--tree> +-is used, the output is formatted in a tree representing parents of each ++'scsi', 'storage', 'fc_host', 'vports', 'scsi_generic', 'drm', 'mdev', ++'mdev_types'. ++If I<--tree> is used, the output is formatted in a tree representing parents of each + node. I and I<--tree> are mutually exclusive. + + =item B I +-- +2.13.0 + diff --git a/SOURCES/libvirt-docs-Provide-a-nodedev-driver-stub-documentation.patch b/SOURCES/libvirt-docs-Provide-a-nodedev-driver-stub-documentation.patch new file mode 100644 index 0000000..f7047b8 --- /dev/null +++ b/SOURCES/libvirt-docs-Provide-a-nodedev-driver-stub-documentation.patch @@ -0,0 +1,237 @@ +From 8c30b1e683b37d67d7fe827f6ab63174c596494e Mon Sep 17 00:00:00 2001 +Message-Id: <8c30b1e683b37d67d7fe827f6ab63174c596494e@dist-git> +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:49 +0200 +Subject: [PATCH] docs: Provide a nodedev driver stub documentation + +There's lot more to document about the nodedev driver, besides PCI and +SR-IOV (even this might need to be extended), but let's start small-ish +and at least have a page for it linked from the drivers.html. + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit a94d431dc46070034de7798f572dc1d257542a50) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + docs/drivers.html.in | 6 +- + docs/drvnodedev.html.in | 189 ++++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 194 insertions(+), 1 deletion(-) + create mode 100644 docs/drvnodedev.html.in + +diff --git a/docs/drivers.html.in b/docs/drivers.html.in +index be7483b9b..61993861e 100644 +--- a/docs/drivers.html.in ++++ b/docs/drivers.html.in +@@ -4,7 +4,11 @@ + +

Internal drivers

+ +-
    ++ + +

    + The libvirt public API delegates its implementation to one or +diff --git a/docs/drvnodedev.html.in b/docs/drvnodedev.html.in +new file mode 100644 +index 000000000..0a3870343 +--- /dev/null ++++ b/docs/drvnodedev.html.in +@@ -0,0 +1,189 @@ ++ ++ ++ ++ ++

    Host device management

    ++ ++

    ++ Libvirt provides management of both physical and virtual host devices ++ (historically also referred to as node devices) like USB, PCI, SCSI, and ++ network devices. This also includes various virtualization capabilities ++ which the aforementioned devices provide for utilization, for example ++ SR-IOV, NPIV, DRM, etc. ++

    ++ ++

    ++ The node device driver provides means to list and show details about host ++ devices (virsh nodedev-list, ++ virsh nodedev-dumpxml), which are generic and can be used ++ with all devices. It also provides means to create and destroy devices ++ (virsh nodedev-create, virsh nodedev-destroy) ++ which are meant to be used to create virtual devices, currently only ++ supported by NPIV ++ (more info about NPIV)). ++ Devices on the host system are arranged in a tree-like hierarchy, with ++ the root node being called computer. The node device driver ++ supports two backends to manage the devices, HAL and udev, with the former ++ being deprecated in favour of the latter. ++

    ++ ++

    ++ The generic format of a host device XML can be seen below. ++ To identify a device both within the host and the device tree hierarchy, ++ the following elements are used: ++

    ++
    ++
    name
    ++
    ++ The device's name will be generated by libvirt using the subsystem, ++ like pci and the device's sysfs basename. ++
    ++
    path
    ++
    ++ Fully qualified sysfs path to the device. ++
    ++
    parent
    ++
    ++ This element identifies the parent node in the device hierarchy. The ++ value of the element will correspond with the device parent's ++ name element or computer if the device does ++ not have any parent. ++
    ++
    driver
    ++
    ++ This elements reports the driver in use for this device. The presence ++ of this element in the output XML depends on whether the underlying ++ device manager (most likely udev) exposes information about the ++ driver. ++
    ++
    capability
    ++
    ++ Describes the device in terms of feature support. The element has one ++ mandatory attribute type the value of which determines ++ the type of the device. Currently recognized values for the attribute ++ are: ++ system, ++ pci, ++ usb, ++ usb_device, ++ net, ++ scsi, ++ scsi_host (Since 0.4.7), ++ fc_host, ++ vports, ++ scsi_target (Since 0.7.3), ++ storage (Since 1.0.4), ++ scsi_generic (Since 1.0.7), ++ drm (Since 3.1.0), and ++ This element can be nested in which case it further specifies a ++ device's capability. Refer to specific device types to see more values ++ for the type attribute which are exclusive. ++
    ++
    ++ ++

    Basic structure of a node device

    ++
    ++<device>
    ++  <name>pci_0000_00_17_0</name>
    ++  <path>/sys/devices/pci0000:00/0000:00:17.0</path>
    ++  <parent>computer</parent>
    ++  <driver>
    ++    <name>ahci</name>
    ++  </driver>
    ++  <capability type='pci'>
    ++...
    ++  </capability>
    ++</device>
    ++ ++
      ++ ++

      PCI host devices

      ++
      ++
      capability
      ++
      ++ When used as top level element, the supported values for the ++ type attribute are pci and ++ phys_function (see SR-IOV below). ++
      ++
      ++
      ++<device>
      ++  <name>pci_0000_04_00_1</name>
      ++  <path>/sys/devices/pci0000:00/0000:00:06.0/0000:04:00.1</path>
      ++  <parent>pci_0000_00_06_0</parent>
      ++  <driver>
      ++    <name>igb</name>
      ++  </driver>
      ++  <capability type='pci'>
      ++    <domain>0</domain>
      ++    <bus>4</bus>
      ++    <slot>0</slot>
      ++    <function>1</function>
      ++    <product id='0x10c9'>82576 Gigabit Network Connection</product>
      ++    <vendor id='0x8086'>Intel Corporation</vendor>
      ++    <iommuGroup number='15'>
      ++      <address domain='0x0000' bus='0x04' slot='0x00' function='0x1'/>
      ++    </iommuGroup>
      ++    <numa node='0'/>
      ++    <pci-express>
      ++      <link validity='cap' port='1' speed='2.5' width='2'/>
      ++      <link validity='sta' speed='2.5' width='2'/>
      ++    </pci-express>
      ++  </capability>
      ++</device>
      ++ ++

      ++ The XML format for a PCI device stays the same for any further ++ capabilities it supports, a single nested <capability> ++ element will be included for each capability the device supports. ++

      ++ ++

      SR-IOV capability

      ++

      ++ Single root input/output virtualization (SR-IOV) allows sharing of the ++ PCIe resources by multiple virtual environments. That is achieved by ++ slicing up a single full-featured physical resource called physical ++ function (PF) into multiple devices called virtual functions (VFs) sharing ++ their configuration with the underlying PF. Despite the SR-IOV ++ specification, the amount of VFs that can be created on a PF varies among ++ manufacturers. ++

      ++ ++

      ++ Suppose the NIC above was also SR-IOV capable, it would ++ also include a nested ++ <capability> element enumerating all virtual ++ functions available on the physical device (physical port) like in the ++ example below. ++

      ++ ++
      ++<capability type='pci'>
      ++...
      ++  <capability type='virt_functions' maxCount='7'>
      ++    <address domain='0x0000' bus='0x04' slot='0x10' function='0x1'/>
      ++    <address domain='0x0000' bus='0x04' slot='0x10' function='0x3'/>
      ++    <address domain='0x0000' bus='0x04' slot='0x10' function='0x5'/>
      ++    <address domain='0x0000' bus='0x04' slot='0x10' function='0x7'/>
      ++    <address domain='0x0000' bus='0x04' slot='0x11' function='0x1'/>
      ++    <address domain='0x0000' bus='0x04' slot='0x11' function='0x3'/>
      ++    <address domain='0x0000' bus='0x04' slot='0x11' function='0x5'/>
      ++  </capability>
      ++...
      ++</capability>
      ++

      ++ A SR-IOV child device on the other hand, would then report its top level ++ capability type as a phys_function instead: ++

      ++ ++
      ++<device>
      ++...
      ++  <capability type='phys_function'>
      ++    <address domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
      ++  </capability>
      ++...
      ++<device>
      ++ ++ ++ +-- +2.13.0 + diff --git a/SOURCES/libvirt-docs-Update-docs-to-reflect-LUKS-secret-changes.patch b/SOURCES/libvirt-docs-Update-docs-to-reflect-LUKS-secret-changes.patch deleted file mode 100644 index cfc2e82..0000000 --- a/SOURCES/libvirt-docs-Update-docs-to-reflect-LUKS-secret-changes.patch +++ /dev/null @@ -1,220 +0,0 @@ -From 778fbc28f6ae7f40082d48bc57c224cd7a8d45d0 Mon Sep 17 00:00:00 2001 -Message-Id: <778fbc28f6ae7f40082d48bc57c224cd7a8d45d0@dist-git> -From: John Ferlan -Date: Mon, 25 Jul 2016 12:42:52 -0400 -Subject: [PATCH] docs: Update docs to reflect LUKS secret changes - -https://bugzilla.redhat.com/show_bug.cgi?id=1301021 - -Commit id's 'c8438010', '9bbf0d7e', and '2552fec24' altered the documentation -to describe adding a 'passphrase' type secret usage model in order to reference -the secret for a luks volume. After commit, it was deemed that a 'volume' -usage model should be used, so adjust the various documents in order rephrase -descriptions in order to follow the correct usage model. - -Signed-off-by: John Ferlan -(cherry picked from commit a6bab5c34313497f80e8bbae5a5da405d3c4264b) - -Resolved some minor formatting conflicts from docs/formatsecret.html.in -since commit id 'c84380106fe69f86842dc7e8c032af6740bef77e' is not present -for downstream - -Signed-off-by: John Ferlan ---- - docs/formatsecret.html.in | 45 +++++++++++++++++++++++++++++------- - docs/formatstorage.html.in | 16 +++++++++++++ - docs/formatstorageencryption.html.in | 29 ++++++++++------------- - 3 files changed, 65 insertions(+), 25 deletions(-) - -diff --git a/docs/formatsecret.html.in b/docs/formatsecret.html.in -index c39d2a7..fd698a4 100644 ---- a/docs/formatsecret.html.in -+++ b/docs/formatsecret.html.in -@@ -41,7 +41,7 @@ -
      - Specifies what this secret is used for. A mandatory - type attribute specifies the usage category, currently -- only volume, ceph and iscsi -+ only volume, ceph, and iscsi - are defined. Specific usage categories are described below. -
      - -@@ -49,10 +49,12 @@ -

      Usage type "volume"

      - -

      -- This secret is associated with a volume, and it is safe to delete the -- secret after the volume is deleted. The <usage -- type='volume'> element must contain a -- single volume element that specifies the key of the volume -+ This secret is associated with a volume, whether the format is either -+ for a "qcow" or a "luks" encrypted volume. Each volume will have a -+ unique secret associated with it and it is safe to delete the -+ secret after the volume is deleted. The -+ <usage type='volume'> element must contain a -+ single volume element that specifies the path of the volume - this secret is associated with. For example, create a volume-secret.xml - file as follows: -

      -@@ -68,7 +70,7 @@ - - -

      -- Define the secret and set the pass phrase as follows: -+ Define the secret and set the passphrase as follows: -

      -
      -       # virsh secret-define volume-secret.xml
      -@@ -81,8 +83,8 @@
      -     
      - -

      -- The volume type secret can then be used in the XML for a storage volume -- encryption as follows: -+ The volume type secret can be supplied in domain XML for a qcow storage -+ volume encryption as follows: -

      -
      -       <encryption format='qcow'>
      -@@ -90,6 +92,33 @@
      -       </encryption>
      -     
      - -+

      -+ The volume type secret can be supplied either in volume XML during -+ creation of a storage volume -+ in order to provide the passphrase to encrypt the volume or in -+ domain XML disk device -+ in order to provide the passphrase to decrypt the volume, -+ since 2.1.0. An example follows: -+

      -+
      -+      # cat luks-secret.xml
      -+      <secret ephemeral='no' private='yes'>
      -+         <description>LUKS Sample Secret</description>
      -+         <uuid>f52a81b2-424e-490c-823d-6bd4235bc57</uuid>
      -+         <usage type='volume'>
      -+            <volume>/var/lib/libvirt/images/luks-sample.img</volume>
      -+         </usage>
      -+      </secret>
      -+
      -+      # virsh secret-define luks-secret.xml
      -+      Secret f52a81b2-424e-490c-823d-6bd4235bc57 created
      -+      #
      -+      # MYSECRET=`printf %s "letmein" | base64`
      -+      # virsh secret-set-value f52a81b2-424e-490c-823d-6bd4235bc57 $MYSECRET
      -+      Secret value set
      -+      #
      -+    
      -+ -

      Usage type "ceph"

      -

      - This secret is associated with a Ceph RBD (rados block device). -diff --git a/docs/formatstorage.html.in b/docs/formatstorage.html.in -index 94277a1..a700e85 100644 ---- a/docs/formatstorage.html.in -+++ b/docs/formatstorage.html.in -@@ -752,5 +752,21 @@ - </permissions> - </target> - </volume> -+ -+

      Storage volume using LUKS

      -+ -+
      -+      <volume>
      -+        <name>MyLuks.img</name>
      -+        <capacity unit="G">5</capacity>
      -+        <target>
      -+          <path>/var/lib/virt/images/MyLuks.img</path>
      -+          <format type='luks'/>
      -+          <encryption format='luks'>
      -+            <secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc572'/>
      -+          </encryption>
      -+        </target>
      -+      </volume>
      -+    
      - - -diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in -index f2b0ffd..11af97e 100644 ---- a/docs/formatstorageencryption.html.in -+++ b/docs/formatstorageencryption.html.in -@@ -27,9 +27,9 @@ - secret tags, each with mandatory attributes type - and either uuid or usage - (since 2.1.0). The only currently defined -- value of type is passphrase. The -+ value of type is volume. The - uuid is "uuid" of the secret while -- usage is the value "usage" subelement field. -+ usage is the "usage" subelement field. - A secret value can be set in libvirt by the - - virSecretSetValue API. Alternatively, if supported -@@ -40,7 +40,7 @@ -

      "default" format

      -

      - <encryption format="default"/> can be specified only -- when creating a volume. If the volume is successfully created, the -+ when creating a qcow volume. If the volume is successfully created, the - encryption formats, parameters and secrets will be auto-generated by - libvirt and the attached encryption tag will be updated. - The unmodified contents of the encryption tag can be used -@@ -59,13 +59,9 @@ -

      "luks" format

      -

      - The luks format is specific to a luks encrypted volume -- and the secret used in order to either encrypt or decrypt the volume. -- A single <secret type='passphrase'...> element is -- expected. The secret may be referenced via either a uuid or -- usage attribute. One of the two must be present. When -- present for volume creation, the secret will be used in order for -- volume encryption. When present for domain usage, the secret will -- be used as the passphrase to decrypt the volume. -+ and the secret is used in order to either encrypt during volume creation -+ or decrypt the volume for usage by the domain. A single -+ <secret type='passphrase'...> element is expected. - Since 2.1.0. -

      -

      -@@ -135,22 +131,21 @@ - </encryption> - -

      -- Assuming a -- luks secret is already defined using a -- usage element with an name of "luks_example", -+ Assuming a -+ luks volume type secret is already defined, - a simple example specifying use of the luks format - for either volume creation without a specific cipher being defined or - as part of a domain volume definition: -

      -
      -       <encryption format='luks'>
      --         <secret type='passphrase' usage='luks_example'/>
      -+        <secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc572'/>
      -       </encryption>
      -     
      - -

      -- Here is an example, specifying use of the luks format for -- a specific cipher algorihm for volume creation: -+ Here is an example specifying use of the luks format for -+ a specific cipher algorithm for volume creation: -

      -
      -       <volume>
      -@@ -160,7 +155,7 @@
      -           <path>/var/lib/libvirt/images/demo.luks</path>
      -           <format type='luks'/>
      -           <encryption format='luks'>
      --             <secret type='passphrase' usage='luks_example'/>
      -+             <secret type='passphrase' uuid='f52a81b2-424e-490c-823d-6bd4235bc572'/>
      -              <cipher name='twofish' size='256' mode='cbc' hash='sha256'/>
      -              <ivgen name='plain64' hash='sha256'/>
      -           </encryption>
      --- 
      -2.9.2
      -
      diff --git a/SOURCES/libvirt-docs-correct-improper-information-about-domain-states-in-virsh-manpage.patch b/SOURCES/libvirt-docs-correct-improper-information-about-domain-states-in-virsh-manpage.patch
      new file mode 100644
      index 0000000..866c030
      --- /dev/null
      +++ b/SOURCES/libvirt-docs-correct-improper-information-about-domain-states-in-virsh-manpage.patch
      @@ -0,0 +1,42 @@
      +From 7a40c13d93a300f6f2c493c864da7342f34e9a6c Mon Sep 17 00:00:00 2001
      +Message-Id: <7a40c13d93a300f6f2c493c864da7342f34e9a6c@dist-git>
      +From: Laine Stump 
      +Date: Tue, 6 Jun 2017 12:07:49 -0400
      +Subject: [PATCH] docs: correct improper information about domain states in
      + virsh manpage
      +
      +Commit 24d4a0a1f removed the non-existent "dying" state from the list
      +of possible domain states given in the virsh manpage, but didn't
      +correct the count of states from 8 down to 7. This patch fixes that
      +mismatch by completely removing any reference to the exact number of
      +states (thus preventing a potential future mismatch), while wording
      +the sentence in a more readable/truthful manner.
      +
      +(cherry picked from commit c44482eb4fb703391f2ee00c23b2187e0415e799)
      +
      +https://bugzilla.redhat.com/show_bug.cgi?id=1408778
      +
      +Signed-off-by: Jiri Denemark 
      +---
      + tools/virsh.pod | 5 +++--
      + 1 file changed, 3 insertions(+), 2 deletions(-)
      +
      +diff --git a/tools/virsh.pod b/tools/virsh.pod
      +index 0315f1f265..6386c39fbc 100644
      +--- a/tools/virsh.pod
      ++++ b/tools/virsh.pod
      +@@ -418,8 +418,9 @@ State is the run state (see below).
      + 
      + B
      + 
      +-The State field lists 8 states for a domain, and which ones the
      +-current domain is in.
      ++The State field lists what state each domain is currently in. A domain
      ++can be in one of the following possible states:
      ++
      + 
      + =over 4
      + 
      +-- 
      +2.13.1
      +
      diff --git a/SOURCES/libvirt-docs-fix-typo-in-closing-HTML-element.patch b/SOURCES/libvirt-docs-fix-typo-in-closing-HTML-element.patch
      new file mode 100644
      index 0000000..0469959
      --- /dev/null
      +++ b/SOURCES/libvirt-docs-fix-typo-in-closing-HTML-element.patch
      @@ -0,0 +1,32 @@
      +From 3983bc29326d6f247d4dc3517ca42896042c02e0 Mon Sep 17 00:00:00 2001
      +Message-Id: <3983bc29326d6f247d4dc3517ca42896042c02e0@dist-git>
      +From: "Daniel P. Berrange" 
      +Date: Tue, 25 Apr 2017 13:41:18 +0200
      +Subject: [PATCH] docs: fix typo in closing HTML element
      +
      +https://bugzilla.redhat.com/show_bug.cgi?id=1414627
      +
      +Signed-off-by: Daniel P. Berrange 
      +(cherry picked from commit dfda3a8ed988e6542294b85b78e816d593b22dc3)
      +Signed-off-by: Martin Kletzander 
      +Signed-off-by: Jiri Denemark 
      +---
      + docs/formatdomain.html.in | 2 +-
      + 1 file changed, 1 insertion(+), 1 deletion(-)
      +
      +diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
      +index 7374cb243..c82cd69a2 100644
      +--- a/docs/formatdomain.html.in
      ++++ b/docs/formatdomain.html.in
      +@@ -5457,7 +5457,7 @@ qemu-kvm -net nic,model=? /dev/null
      +       This element provides means of setting coalesce settings for
      +       some interface devices (currently only type network
      +       and bridge.  Currently there is just one attribute,
      +-      max, to tweak, in element frames for
      ++      max, to tweak, in element frames for
      +       the rx group, which accepts a non-negative integer
      +       that specifies the maximum number of packets that will be
      +       received before an interrupt.
      +-- 
      +2.12.2
      +
      diff --git a/SOURCES/libvirt-encryption-Add-cipher-and-ivgen-to-encryption.patch b/SOURCES/libvirt-encryption-Add-cipher-and-ivgen-to-encryption.patch
      deleted file mode 100644
      index fa3e49e..0000000
      --- a/SOURCES/libvirt-encryption-Add-cipher-and-ivgen-to-encryption.patch
      +++ /dev/null
      @@ -1,599 +0,0 @@
      -From 629e64743474a040863ef1267eb48568c6e3e80c Mon Sep 17 00:00:00 2001
      -Message-Id: <629e64743474a040863ef1267eb48568c6e3e80c@dist-git>
      -From: John Ferlan 
      -Date: Mon, 25 Jul 2016 12:42:49 -0400
      -Subject: [PATCH] encryption: Add  and  to encryption
      -
      -https://bugzilla.redhat.com/show_bug.cgi?id=1301021
      -
      -For a luks device, allow the configuration of a specific cipher to be
      -used for encrypting the volume.
      -
      -Signed-off-by: John Ferlan 
      -(cherry picked from commit 2552fec248c665f3417a5d36840555da6bbe96a4)
      ----
      - docs/formatstorageencryption.html.in               |  83 ++++++++++++-
      - docs/schemas/storagecommon.rng                     |  44 ++++++-
      - src/conf/domain_conf.c                             |  11 ++
      - src/util/virstorageencryption.c                    | 136 +++++++++++++++++++++
      - src/util/virstorageencryption.h                    |  14 +++
      - .../qemuxml2argv-luks-disk-cipher.xml              |  45 +++++++
      - .../qemuxml2xmlout-luks-disk-cipher.xml            |   1 +
      - tests/qemuxml2xmltest.c                            |   1 +
      - tests/storagevolxml2xmlin/vol-luks-cipher.xml      |  23 ++++
      - tests/storagevolxml2xmlout/vol-luks-cipher.xml     |  23 ++++
      - tests/storagevolxml2xmltest.c                      |   1 +
      - 11 files changed, 376 insertions(+), 6 deletions(-)
      - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-luks-disk-cipher.xml
      - create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disk-cipher.xml
      - create mode 100644 tests/storagevolxml2xmlin/vol-luks-cipher.xml
      - create mode 100644 tests/storagevolxml2xmlout/vol-luks-cipher.xml
      -
      -diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in
      -index 380763e..f2b0ffd 100644
      ---- a/docs/formatstorageencryption.html.in
      -+++ b/docs/formatstorageencryption.html.in
      -@@ -68,6 +68,60 @@
      -       be used as the passphrase to decrypt the volume.
      -       Since 2.1.0.
      -     

      -+

      -+ For volume creation, it is possible to specify the encryption -+ algorithm used to encrypt the luks volume. The following two -+ optional elements may be provided for that purpose. It is hypervisor -+ dependent as to which algorithms are supported. The default algorithm -+ used by the storage driver backend when using qemu-img to create -+ the volume is 'aes-256-cbc' using 'essiv' for initialization vector -+ generation and 'sha256' hash algorithm for both the cipher and the -+ initialization vector generation. -+

      -+ -+
      -+
      cipher
      -+
      This element describes the cipher algorithm to be used to either -+ encrypt or decrypt the luks volume. This element has the following -+ attributes: -+
      -+
      name
      -+
      The name of the cipher algorithm used for data encryption, -+ such as 'aes', 'des', 'cast5', 'serpent', 'twofish', etc. -+ Support of the specific algorithm is storage driver -+ implementation dependent.
      -+
      size
      -+
      The size of the cipher in bits, such as '256', '192', '128', -+ etc. Support of the specific size for a specific cipher is -+ hypervisor dependent.
      -+
      mode
      -+
      An optional cipher algorithm mode such as 'cbc', 'xts', -+ 'ecb', etc. Support of the specific cipher mode is -+ hypervisor dependent.
      -+
      hash
      -+
      An optional master key hash algorithm such as 'md5', 'sha1', -+ 'sha256', etc. Support of the specific hash algorithm is -+ hypervisor dependent.
      -+
      -+
      -+
      ivgen
      -+
      This optional element describes the initialization vector -+ generation algorithm used in conjunction with the -+ cipher. If the cipher is not provided, -+ then an error will be generated by the parser. -+
      -+
      name
      -+
      The name of the algorithm, such as 'plain', 'plain64', -+ 'essiv', etc. Support of the specific algorithm is hypervisor -+ dependent.
      -+
      hash
      -+
      An optional hash algorithm such as 'md5', 'sha1', 'sha256', -+ etc. Support of the specific ivgen hash algorithm is hypervisor -+ dependent.
      -+
      -+
      -+
      -+ - -

      Examples

      - -@@ -81,9 +135,12 @@ - </encryption>
      - -

      -- Here is a simple example, specifying use of the luks format -- where it's assumed that a secret has been defined using a -- usage element with a id of "luks_example": -+ Assuming a -+ luks secret is already defined using a -+ usage element with an name of "luks_example", -+ a simple example specifying use of the luks format -+ for either volume creation without a specific cipher being defined or -+ as part of a domain volume definition: -

      -
      -       <encryption format='luks'>
      -@@ -91,5 +148,25 @@
      -       </encryption>
      -     
      - -+

      -+ Here is an example, specifying use of the luks format for -+ a specific cipher algorihm for volume creation: -+

      -+
      -+      <volume>
      -+        <name>twofish.luks</name>
      -+        <capacity unit='G'>5</capacity>
      -+        <target>
      -+          <path>/var/lib/libvirt/images/demo.luks</path>
      -+          <format type='luks'/>
      -+          <encryption format='luks'>
      -+             <secret type='passphrase' usage='luks_example'/>
      -+             <cipher name='twofish' size='256' mode='cbc' hash='sha256'/>
      -+             <ivgen name='plain64' hash='sha256'/>
      -+          </encryption>
      -+        </target>
      -+      </volume>
      -+    
      -+ - - -diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng -index 63b55b4..316fbae 100644 ---- a/docs/schemas/storagecommon.rng -+++ b/docs/schemas/storagecommon.rng -@@ -15,9 +15,19 @@ - luks - - -- -- -- -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - - - -@@ -136,4 +146,32 @@ - - - -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 8b9b623..abf889a 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -7869,6 +7869,17 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, - def->startupPolicy = val; - } - -+ if (encryption) { -+ if (encryption->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && -+ encryption->encinfo.cipher_name) { -+ -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("supplying the for a domain is " -+ "unnecessary")); -+ goto error; -+ } -+ } -+ - def->dst = target; - target = NULL; - def->src->auth = authdef; -diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c -index 2b59420..116a235 100644 ---- a/src/util/virstorageencryption.c -+++ b/src/util/virstorageencryption.c -@@ -35,6 +35,7 @@ - #include "viruuid.h" - #include "virfile.h" - #include "virsecret.h" -+#include "virstring.h" - - #define VIR_FROM_THIS VIR_FROM_STORAGE - -@@ -46,6 +47,17 @@ VIR_ENUM_IMPL(virStorageEncryptionFormat, - "default", "qcow", "luks") - - static void -+virStorageEncryptionInfoDefFree(virStorageEncryptionInfoDefPtr def) -+{ -+ VIR_FREE(def->cipher_name); -+ VIR_FREE(def->cipher_mode); -+ VIR_FREE(def->cipher_hash); -+ VIR_FREE(def->ivgen_name); -+ VIR_FREE(def->ivgen_hash); -+} -+ -+ -+static void - virStorageEncryptionSecretFree(virStorageEncryptionSecretPtr secret) - { - if (!secret) -@@ -64,6 +76,7 @@ virStorageEncryptionFree(virStorageEncryptionPtr enc) - - for (i = 0; i < enc->nsecrets; i++) - virStorageEncryptionSecretFree(enc->secrets[i]); -+ virStorageEncryptionInfoDefFree(&enc->encinfo); - VIR_FREE(enc->secrets); - VIR_FREE(enc); - } -@@ -81,6 +94,23 @@ virStorageEncryptionSecretCopy(const virStorageEncryptionSecret *src) - return ret; - } - -+ -+static int -+virStorageEncryptionInfoDefCopy(const virStorageEncryptionInfoDef *src, -+ virStorageEncryptionInfoDefPtr dst) -+{ -+ dst->cipher_size = src->cipher_size; -+ if (VIR_STRDUP(dst->cipher_name, src->cipher_name) < 0 || -+ VIR_STRDUP(dst->cipher_mode, src->cipher_mode) < 0 || -+ VIR_STRDUP(dst->cipher_hash, src->cipher_hash) < 0 || -+ VIR_STRDUP(dst->ivgen_name, src->ivgen_name) < 0 || -+ VIR_STRDUP(dst->ivgen_hash, src->ivgen_hash) < 0) -+ return -1; -+ -+ return 0; -+} -+ -+ - virStorageEncryptionPtr - virStorageEncryptionCopy(const virStorageEncryption *src) - { -@@ -101,6 +131,9 @@ virStorageEncryptionCopy(const virStorageEncryption *src) - goto error; - } - -+ if (virStorageEncryptionInfoDefCopy(&src->encinfo, &ret->encinfo) < 0) -+ goto error; -+ - return ret; - - error: -@@ -154,6 +187,61 @@ virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt, - return NULL; - } - -+ -+static int -+virStorageEncryptionInfoParseCipher(xmlNodePtr info_node, -+ virStorageEncryptionInfoDefPtr info) -+{ -+ int ret = -1; -+ char *size_str = NULL; -+ -+ if (!(info->cipher_name = virXMLPropString(info_node, "name"))) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("cipher info missing 'name' attribute")); -+ goto cleanup; -+ } -+ -+ if ((size_str = virXMLPropString(info_node, "size")) && -+ virStrToLong_uip(size_str, NULL, 10, &info->cipher_size) < 0) { -+ virReportError(VIR_ERR_XML_ERROR, -+ _("cannot parse cipher size: '%s'"), -+ size_str); -+ goto cleanup; -+ } -+ -+ if (!size_str) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("cipher info missing 'size' attribute")); -+ goto cleanup; -+ } -+ -+ info->cipher_mode = virXMLPropString(info_node, "mode"); -+ info->cipher_hash = virXMLPropString(info_node, "hash"); -+ -+ ret = 0; -+ -+ cleanup: -+ VIR_FREE(size_str); -+ return ret; -+} -+ -+ -+static int -+virStorageEncryptionInfoParseIvgen(xmlNodePtr info_node, -+ virStorageEncryptionInfoDefPtr info) -+{ -+ if (!(info->ivgen_name = virXMLPropString(info_node, "name"))) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("missing ivgen info name string")); -+ return -1; -+ } -+ -+ info->ivgen_hash = virXMLPropString(info_node, "hash"); -+ -+ return 0; -+} -+ -+ - static virStorageEncryptionPtr - virStorageEncryptionParseXML(xmlXPathContextPtr ctxt) - { -@@ -197,6 +285,28 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt) - VIR_FREE(nodes); - } - -+ if (ret->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS) { -+ xmlNodePtr tmpnode; -+ -+ if ((tmpnode = virXPathNode("./cipher[1]", ctxt))) { -+ if (virStorageEncryptionInfoParseCipher(tmpnode, &ret->encinfo) < 0) -+ goto cleanup; -+ } -+ -+ if ((tmpnode = virXPathNode("./ivgen[1]", ctxt))) { -+ /* If no cipher node, then fail */ -+ if (!ret->encinfo.cipher_name) { -+ virReportError(VIR_ERR_XML_ERROR, "%s", -+ _("ivgen element found, but cipher is missing")); -+ goto cleanup; -+ } -+ -+ if (virStorageEncryptionInfoParseIvgen(tmpnode, &ret->encinfo) < 0) -+ goto cleanup; -+ } -+ } -+ -+ - return ret; - - cleanup: -@@ -251,6 +361,28 @@ virStorageEncryptionSecretFormat(virBufferPtr buf, - return 0; - } - -+ -+static void -+virStorageEncryptionInfoDefFormat(virBufferPtr buf, -+ const virStorageEncryptionInfoDef *enc) -+{ -+ virBufferEscapeString(buf, "cipher_name); -+ virBufferAsprintf(buf, " size='%u'", enc->cipher_size); -+ if (enc->cipher_mode) -+ virBufferEscapeString(buf, " mode='%s'", enc->cipher_mode); -+ if (enc->cipher_hash) -+ virBufferEscapeString(buf, " hash='%s'", enc->cipher_hash); -+ virBufferAddLit(buf, "/>\n"); -+ -+ if (enc->ivgen_name) { -+ virBufferEscapeString(buf, "ivgen_name); -+ if (enc->ivgen_hash) -+ virBufferEscapeString(buf, " hash='%s'", enc->ivgen_hash); -+ virBufferAddLit(buf, "/>\n"); -+ } -+} -+ -+ - int - virStorageEncryptionFormat(virBufferPtr buf, - virStorageEncryptionPtr enc) -@@ -271,6 +403,10 @@ virStorageEncryptionFormat(virBufferPtr buf, - return -1; - } - -+ if (enc->format == VIR_STORAGE_ENCRYPTION_FORMAT_LUKS && -+ enc->encinfo.cipher_name) -+ virStorageEncryptionInfoDefFormat(buf, &enc->encinfo); -+ - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - -diff --git a/src/util/virstorageencryption.h b/src/util/virstorageencryption.h -index 5e1be3b..fa439fb 100644 ---- a/src/util/virstorageencryption.h -+++ b/src/util/virstorageencryption.h -@@ -44,6 +44,18 @@ struct _virStorageEncryptionSecret { - virSecretLookupTypeDef seclookupdef; - }; - -+/* It's possible to dictate the cipher and if necessary iv */ -+typedef struct _virStorageEncryptionInfoDef virStorageEncryptionInfoDef; -+typedef virStorageEncryptionInfoDef *virStorageEncryptionInfoDefPtr; -+struct _virStorageEncryptionInfoDef { -+ unsigned int cipher_size; -+ char *cipher_name; -+ char *cipher_mode; -+ char *cipher_hash; -+ char *ivgen_name; -+ char *ivgen_hash; -+}; -+ - typedef enum { - /* "default" is only valid for volume creation */ - VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT = 0, -@@ -61,6 +73,8 @@ struct _virStorageEncryption { - - size_t nsecrets; - virStorageEncryptionSecretPtr *secrets; -+ -+ virStorageEncryptionInfoDef encinfo; - }; - - virStorageEncryptionPtr virStorageEncryptionCopy(const virStorageEncryption *src) -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-luks-disk-cipher.xml b/tests/qemuxml2argvdata/qemuxml2argv-luks-disk-cipher.xml -new file mode 100644 -index 0000000..9ce15c0 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-luks-disk-cipher.xml -@@ -0,0 +1,45 @@ -+ -+ encryptdisk -+ 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 -+ 1048576 -+ 524288 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+ -+ -+ -+ -+
      -+ -+ -+ -+ -+ -+ -+ -+ -+
      -+ -+ -+
      -+ -+ -+ -+ -+ -+
      -+ -+ -+ -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disk-cipher.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disk-cipher.xml -new file mode 120000 -index 0000000..fa55233 ---- /dev/null -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disk-cipher.xml -@@ -0,0 +1 @@ -+../qemuxml2argvdata/qemuxml2argv-luks-disk-cipher.xml -\ No newline at end of file -diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c -index a757fdb..d00d209 100644 ---- a/tests/qemuxml2xmltest.c -+++ b/tests/qemuxml2xmltest.c -@@ -503,6 +503,7 @@ mymain(void) - DO_TEST("encrypted-disk"); - DO_TEST("encrypted-disk-usage"); - DO_TEST("luks-disks"); -+ DO_TEST("luks-disk-cipher"); - DO_TEST("memtune"); - DO_TEST("memtune-unlimited"); - DO_TEST("blkiotune"); -diff --git a/tests/storagevolxml2xmlin/vol-luks-cipher.xml b/tests/storagevolxml2xmlin/vol-luks-cipher.xml -new file mode 100644 -index 0000000..009246f ---- /dev/null -+++ b/tests/storagevolxml2xmlin/vol-luks-cipher.xml -@@ -0,0 +1,23 @@ -+ -+ LuksDemo.img -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 5 -+ 294912 -+ -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 0644 -+ 0 -+ 0 -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/storagevolxml2xmlout/vol-luks-cipher.xml b/tests/storagevolxml2xmlout/vol-luks-cipher.xml -new file mode 100644 -index 0000000..9014849 ---- /dev/null -+++ b/tests/storagevolxml2xmlout/vol-luks-cipher.xml -@@ -0,0 +1,23 @@ -+ -+ LuksDemo.img -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 5368709120 -+ 294912 -+ -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 0644 -+ 0 -+ 0 -+ -+ -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c -index a36a706..db82bea 100644 ---- a/tests/storagevolxml2xmltest.c -+++ b/tests/storagevolxml2xmltest.c -@@ -106,6 +106,7 @@ mymain(void) - DO_TEST("pool-dir", "vol-qcow2-0.10-lazy"); - DO_TEST("pool-dir", "vol-qcow2-nobacking"); - DO_TEST("pool-dir", "vol-luks"); -+ DO_TEST("pool-dir", "vol-luks-cipher"); - DO_TEST("pool-disk", "vol-partition"); - DO_TEST("pool-logical", "vol-logical"); - DO_TEST("pool-logical", "vol-logical-backing"); --- -2.9.2 - diff --git a/SOURCES/libvirt-encryption-Add-luks-parsing-for-storageencryption.patch b/SOURCES/libvirt-encryption-Add-luks-parsing-for-storageencryption.patch deleted file mode 100644 index 570c4cc..0000000 --- a/SOURCES/libvirt-encryption-Add-luks-parsing-for-storageencryption.patch +++ /dev/null @@ -1,330 +0,0 @@ -From 155f32761f7f6569fde7c4c718169fb4f514d2c3 Mon Sep 17 00:00:00 2001 -Message-Id: <155f32761f7f6569fde7c4c718169fb4f514d2c3@dist-git> -From: John Ferlan -Date: Mon, 25 Jul 2016 12:42:48 -0400 -Subject: [PATCH] encryption: Add luks parsing for storageencryption - -https://bugzilla.redhat.com/show_bug.cgi?id=1301021 - -Add parse and format of the luks/passphrase secret including tests for -volume XML parsing. - -Signed-off-by: John Ferlan -(cherry picked from commit 9bbf0d7e6457e5a0668017eb8e17276f747fc9cc) - -Resolved conflict in docs/formatsecret.html.in since commit id -c84380106fe69f86842dc7e8c032af6740bef77e is not present downstream - -Signed-off-by: John Ferlan ---- - docs/formatstorageencryption.html.in | 26 ++++++++++++- - docs/schemas/storagecommon.rng | 2 + - src/qemu/qemu_process.c | 6 +++ - src/storage/storage_backend.c | 3 +- - src/storage/storage_backend_fs.c | 7 +++- - src/storage/storage_backend_gluster.c | 2 + - src/util/virstorageencryption.c | 2 +- - src/util/virstorageencryption.h | 1 + - tests/qemuxml2argvdata/qemuxml2argv-luks-disks.xml | 45 ++++++++++++++++++++++ - .../qemuxml2xmlout-luks-disks.xml | 1 + - tests/qemuxml2xmltest.c | 1 + - tests/storagevolxml2xmlin/vol-luks.xml | 21 ++++++++++ - tests/storagevolxml2xmlout/vol-luks.xml | 21 ++++++++++ - tests/storagevolxml2xmltest.c | 1 + - 14 files changed, 134 insertions(+), 5 deletions(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-luks-disks.xml - create mode 120000 tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disks.xml - create mode 100644 tests/storagevolxml2xmlin/vol-luks.xml - create mode 100644 tests/storagevolxml2xmlout/vol-luks.xml - -diff --git a/docs/formatstorageencryption.html.in b/docs/formatstorageencryption.html.in -index 58e1073..380763e 100644 ---- a/docs/formatstorageencryption.html.in -+++ b/docs/formatstorageencryption.html.in -@@ -56,8 +56,20 @@ - the secret element is not present during volume creation, - a secret is automatically generated and attached to the volume. -

      -+

      "luks" format

      -+

      -+ The luks format is specific to a luks encrypted volume -+ and the secret used in order to either encrypt or decrypt the volume. -+ A single <secret type='passphrase'...> element is -+ expected. The secret may be referenced via either a uuid or -+ usage attribute. One of the two must be present. When -+ present for volume creation, the secret will be used in order for -+ volume encryption. When present for domain usage, the secret will -+ be used as the passphrase to decrypt the volume. -+ Since 2.1.0. -+

      - --

      Example

      -+

      Examples

      - -

      - Here is a simple example, specifying use of the qcow format: -@@ -67,5 +79,17 @@ - <encryption format='qcow'> - <secret type='passphrase' uuid='c1f11a6d-8c5d-4a3e-ac7a-4e171c5e0d4a' /> - </encryption> -+ -+

      -+ Here is a simple example, specifying use of the luks format -+ where it's assumed that a secret has been defined using a -+ usage element with a id of "luks_example": -+

      -+
      -+      <encryption format='luks'>
      -+         <secret type='passphrase' usage='luks_example'/>
      -+      </encryption>
      -+    
      -+ - - -diff --git a/docs/schemas/storagecommon.rng b/docs/schemas/storagecommon.rng -index c5b71de..63b55b4 100644 ---- a/docs/schemas/storagecommon.rng -+++ b/docs/schemas/storagecommon.rng -@@ -12,6 +12,7 @@ - - default - qcow -+ luks - - - -@@ -81,6 +82,7 @@ - fat - vhd - ploop -+ luks - - - -diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c -index 4ffd9b7..129c070 100644 ---- a/src/qemu/qemu_process.c -+++ b/src/qemu/qemu_process.c -@@ -2414,6 +2414,12 @@ qemuProcessInitPasswords(virConnectPtr conn, - !virDomainDiskGetSource(vm->def->disks[i])) - continue; - -+ if (vm->def->disks[i]->src->encryption->format != -+ VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT && -+ vm->def->disks[i]->src->encryption->format != -+ VIR_STORAGE_ENCRYPTION_FORMAT_QCOW) -+ continue; -+ - VIR_FREE(secret); - if (qemuProcessGetVolumeQcowPassphrase(conn, - vm->def->disks[i], -diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c -index d6a451d..97f6ffe 100644 ---- a/src/storage/storage_backend.c -+++ b/src/storage/storage_backend.c -@@ -1027,8 +1027,7 @@ virStorageBackendCreateQemuImgCheckEncryption(int format, - } - } else { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, -- _("qcow volume encryption unsupported with " -- "volume format %s"), type); -+ _("volume encryption unsupported with format %s"), type); - return -1; - } - -diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c -index 839a2c7..0a12ecb 100644 ---- a/src/storage/storage_backend_fs.c -+++ b/src/storage/storage_backend_fs.c -@@ -157,7 +157,12 @@ virStorageBackendProbeTarget(virStorageSourcePtr target, - case VIR_STORAGE_FILE_QCOW2: - (*encryption)->format = VIR_STORAGE_ENCRYPTION_FORMAT_QCOW; - break; -- default: -+ -+ case VIR_STORAGE_FILE_LUKS: -+ (*encryption)->format = VIR_STORAGE_ENCRYPTION_FORMAT_LUKS; -+ break; -+ -+ case VIR_STORAGE_ENCRYPTION_FORMAT_LAST: - break; - } - -diff --git a/src/storage/storage_backend_gluster.c b/src/storage/storage_backend_gluster.c -index 0085052..eda060d 100644 ---- a/src/storage/storage_backend_gluster.c -+++ b/src/storage/storage_backend_gluster.c -@@ -321,6 +321,8 @@ virStorageBackendGlusterRefreshVol(virStorageBackendGlusterStatePtr state, - if (vol->target.format == VIR_STORAGE_FILE_QCOW || - vol->target.format == VIR_STORAGE_FILE_QCOW2) - vol->target.encryption->format = VIR_STORAGE_ENCRYPTION_FORMAT_QCOW; -+ if (vol->target.format == VIR_STORAGE_FILE_LUKS) -+ vol->target.encryption->format = VIR_STORAGE_ENCRYPTION_FORMAT_LUKS; - } - vol->target.features = meta->features; - meta->features = NULL; -diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c -index cd17554..2b59420 100644 ---- a/src/util/virstorageencryption.c -+++ b/src/util/virstorageencryption.c -@@ -43,7 +43,7 @@ VIR_ENUM_IMPL(virStorageEncryptionSecret, - - VIR_ENUM_IMPL(virStorageEncryptionFormat, - VIR_STORAGE_ENCRYPTION_FORMAT_LAST, -- "default", "qcow") -+ "default", "qcow", "luks") - - static void - virStorageEncryptionSecretFree(virStorageEncryptionSecretPtr secret) -diff --git a/src/util/virstorageencryption.h b/src/util/virstorageencryption.h -index c68c66e..5e1be3b 100644 ---- a/src/util/virstorageencryption.h -+++ b/src/util/virstorageencryption.h -@@ -48,6 +48,7 @@ typedef enum { - /* "default" is only valid for volume creation */ - VIR_STORAGE_ENCRYPTION_FORMAT_DEFAULT = 0, - VIR_STORAGE_ENCRYPTION_FORMAT_QCOW, /* Both qcow and qcow2 */ -+ VIR_STORAGE_ENCRYPTION_FORMAT_LUKS, - - VIR_STORAGE_ENCRYPTION_FORMAT_LAST, - } virStorageEncryptionFormatType; -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.xml b/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.xml -new file mode 100644 -index 0000000..9ce15c0 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.xml -@@ -0,0 +1,45 @@ -+ -+ encryptdisk -+ 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 -+ 1048576 -+ 524288 -+ 1 -+ -+ hvm -+ -+ -+ -+ destroy -+ restart -+ destroy -+ -+ /usr/bin/qemu -+ -+ -+ -+ -+ -+ -+ -+
      -+ -+ -+ -+ -+ -+ -+ -+ -+
      -+ -+ -+
      -+ -+ -+ -+ -+ -+
      -+ -+ -+ -diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disks.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disks.xml -new file mode 120000 -index 0000000..b59dc67 ---- /dev/null -+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-luks-disks.xml -@@ -0,0 +1 @@ -+../qemuxml2argvdata/qemuxml2argv-luks-disks.xml -\ No newline at end of file -diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c -index 693e712..a757fdb 100644 ---- a/tests/qemuxml2xmltest.c -+++ b/tests/qemuxml2xmltest.c -@@ -502,6 +502,7 @@ mymain(void) - - DO_TEST("encrypted-disk"); - DO_TEST("encrypted-disk-usage"); -+ DO_TEST("luks-disks"); - DO_TEST("memtune"); - DO_TEST("memtune-unlimited"); - DO_TEST("blkiotune"); -diff --git a/tests/storagevolxml2xmlin/vol-luks.xml b/tests/storagevolxml2xmlin/vol-luks.xml -new file mode 100644 -index 0000000..eb4dc41 ---- /dev/null -+++ b/tests/storagevolxml2xmlin/vol-luks.xml -@@ -0,0 +1,21 @@ -+ -+ LuksDemo.img -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 5 -+ 294912 -+ -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 0644 -+ 0 -+ 0 -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/storagevolxml2xmlout/vol-luks.xml b/tests/storagevolxml2xmlout/vol-luks.xml -new file mode 100644 -index 0000000..5b764b7 ---- /dev/null -+++ b/tests/storagevolxml2xmlout/vol-luks.xml -@@ -0,0 +1,21 @@ -+ -+ LuksDemo.img -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 5368709120 -+ 294912 -+ -+ /var/lib/libvirt/images/LuksDemo.img -+ -+ -+ 0644 -+ 0 -+ 0 -+ -+ -+ -+ -+ -+ -+ -diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c -index f722452..a36a706 100644 ---- a/tests/storagevolxml2xmltest.c -+++ b/tests/storagevolxml2xmltest.c -@@ -105,6 +105,7 @@ mymain(void) - DO_TEST("pool-dir", "vol-qcow2-lazy"); - DO_TEST("pool-dir", "vol-qcow2-0.10-lazy"); - DO_TEST("pool-dir", "vol-qcow2-nobacking"); -+ DO_TEST("pool-dir", "vol-luks"); - DO_TEST("pool-disk", "vol-partition"); - DO_TEST("pool-logical", "vol-logical"); - DO_TEST("pool-logical", "vol-logical-backing"); --- -2.9.2 - diff --git a/SOURCES/libvirt-hvsupport-Introduce-parseSymsFile.patch b/SOURCES/libvirt-hvsupport-Introduce-parseSymsFile.patch deleted file mode 100644 index e904b3e..0000000 --- a/SOURCES/libvirt-hvsupport-Introduce-parseSymsFile.patch +++ /dev/null @@ -1,225 +0,0 @@ -From db426d18a3f337f699540943e0be1dabcaddd001 Mon Sep 17 00:00:00 2001 -Message-Id: -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Tue, 28 Jun 2016 12:37:50 +0200 -Subject: [PATCH] hvsupport: Introduce parseSymsFile - -The code for parsing the different public syms files only differs -in the filenames and version prefix. - -Unify it to a single subroutine. - -(cherry picked from commit fa0b00f94e5173fc1c609e661d74ad9f2f81126c) - -https://bugzilla.redhat.com/show_bug.cgi?id=1286679 -Signed-off-by: Jiri Denemark ---- - docs/hvsupport.pl | 178 +++++++++++++++++------------------------------------- - 1 file changed, 55 insertions(+), 123 deletions(-) - -diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl -index 44a30ce..7a6f1ac 100755 ---- a/docs/hvsupport.pl -+++ b/docs/hvsupport.pl -@@ -44,136 +44,66 @@ find({ - push @srcs, $_ if $_ !~ /vbox_driver\.c/; - } - }, no_chdir => 1}, $srcdir); --my $line; - --# Get the list of all public APIs and their corresponding version -+sub parseSymsFile { -+ my $apisref = shift; -+ my $prefix = shift; -+ my $filename = shift; -+ my $xmlfilename = shift; -+ -+ my $line; -+ my $vers; -+ my $prevvers; -+ -+ my $apixpath = XML::XPath->new(filename => $xmlfilename); -+ -+ open FILE, "<$filename" -+ or die "cannot read $filename: $!"; -+ -+ while (defined($line = )) { -+ chomp $line; -+ next if $line =~ /^\s*#/; -+ next if $line =~ /^\s*$/; -+ next if $line =~ /^\s*(global|local):/; -+ if ($line =~ /^\s*${prefix}_(\d+\.\d+\.\d+)\s*{\s*$/) { -+ if (defined $vers) { -+ die "malformed syms file"; -+ } -+ $vers = $1; -+ } elsif ($line =~ /\s*}\s*;\s*$/) { -+ if (defined $prevvers) { -+ die "malformed syms file"; -+ } -+ $prevvers = $vers; -+ $vers = undef; -+ } elsif ($line =~ /\s*}\s*${prefix}_(\d+\.\d+\.\d+)\s*;\s*$/) { -+ if ($1 ne $prevvers) { -+ die "malformed syms file $1 != $vers"; -+ } -+ $prevvers = $vers; -+ $vers = undef; -+ } elsif ($line =~ /\s*(\w+)\s*;\s*$/) { -+ my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file"); -+ $$apisref{$1} = {}; -+ $$apisref{$1}->{vers} = $vers; -+ $$apisref{$1}->{file} = $file; -+ } else { -+ die "unexpected data $line\n"; -+ } -+ } -+ -+ close FILE; -+} - - my %apis; --open FILE, "<$symslibvirt" -- or die "cannot read $symslibvirt: $!"; -- --my $vers; --my $prevvers; --my $apixpath = XML::XPath->new(filename => "$srcdir/../docs/libvirt-api.xml"); --while (defined($line = )) { -- chomp $line; -- next if $line =~ /^\s*#/; -- next if $line =~ /^\s*$/; -- next if $line =~ /^\s*(global|local):/; -- if ($line =~ /^\s*LIBVIRT_(\d+\.\d+\.\d+)\s*{\s*$/) { -- if (defined $vers) { -- die "malformed syms file"; -- } -- $vers = $1; -- } elsif ($line =~ /\s*}\s*;\s*$/) { -- if (defined $prevvers) { -- die "malformed syms file"; -- } -- $prevvers = $vers; -- $vers = undef; -- } elsif ($line =~ /\s*}\s*LIBVIRT_(\d+\.\d+\.\d+)\s*;\s*$/) { -- if ($1 ne $prevvers) { -- die "malformed syms file $1 != $vers"; -- } -- $prevvers = $vers; -- $vers = undef; -- } elsif ($line =~ /\s*(\w+)\s*;\s*$/) { -- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file"); -- $apis{$1} = {}; -- $apis{$1}->{vers} = $vers; -- $apis{$1}->{file} = $file; -- } else { -- die "unexpected data $line\n"; -- } --} -- --close FILE; -- -+# Get the list of all public APIs and their corresponding version -+parseSymsFile(\%apis, "LIBVIRT", $symslibvirt, "$srcdir/../docs/libvirt-api.xml"); - - # And the same for the QEMU specific APIs -- --open FILE, "<$symsqemu" -- or die "cannot read $symsqemu: $!"; -- --$prevvers = undef; --$vers = undef; --$apixpath = XML::XPath->new(filename => "$srcdir/../docs/libvirt-qemu-api.xml"); --while (defined($line = )) { -- chomp $line; -- next if $line =~ /^\s*#/; -- next if $line =~ /^\s*$/; -- next if $line =~ /^\s*(global|local):/; -- if ($line =~ /^\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*{\s*$/) { -- if (defined $vers) { -- die "malformed syms file"; -- } -- $vers = $1; -- } elsif ($line =~ /\s*}\s*;\s*$/) { -- if (defined $prevvers) { -- die "malformed syms file"; -- } -- $prevvers = $vers; -- $vers = undef; -- } elsif ($line =~ /\s*}\s*LIBVIRT_QEMU_(\d+\.\d+\.\d+)\s*;\s*$/) { -- if ($1 ne $prevvers) { -- die "malformed syms file $1 != $vers"; -- } -- $prevvers = $vers; -- $vers = undef; -- } elsif ($line =~ /\s*(\w+)\s*;\s*$/) { -- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file"); -- $apis{$1} = {}; -- $apis{$1}->{vers} = $vers; -- $apis{$1}->{file} = $file; -- } else { -- die "unexpected data $line\n"; -- } --} -- --close FILE; -- -+parseSymsFile(\%apis, "LIBVIRT_QEMU", $symsqemu, "$srcdir/../docs/libvirt-qemu-api.xml"); - - # And the same for the LXC specific APIs -- --open FILE, "<$symslxc" -- or die "cannot read $symslxc: $!"; -- --$prevvers = undef; --$vers = undef; --$apixpath = XML::XPath->new(filename => "$srcdir/../docs/libvirt-lxc-api.xml"); --while (defined($line = )) { -- chomp $line; -- next if $line =~ /^\s*#/; -- next if $line =~ /^\s*$/; -- next if $line =~ /^\s*(global|local):/; -- if ($line =~ /^\s*LIBVIRT_LXC_(\d+\.\d+\.\d+)\s*{\s*$/) { -- if (defined $vers) { -- die "malformed syms file"; -- } -- $vers = $1; -- } elsif ($line =~ /\s*}\s*;\s*$/) { -- if (defined $prevvers) { -- die "malformed syms file"; -- } -- $prevvers = $vers; -- $vers = undef; -- } elsif ($line =~ /\s*}\s*LIBVIRT_LXC_(\d+\.\d+\.\d+)\s*;\s*$/) { -- if ($1 ne $prevvers) { -- die "malformed syms file $1 != $vers"; -- } -- $prevvers = $vers; -- $vers = undef; -- } elsif ($line =~ /\s*(\w+)\s*;\s*$/) { -- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file"); -- $apis{$1} = {}; -- $apis{$1}->{vers} = $vers; -- $apis{$1}->{file} = $file; -- } else { -- die "unexpected data $line\n"; -- } --} -- --close FILE; -+parseSymsFile(\%apis, "LIBVIRT_LXC", $symslxc, "$srcdir/../docs/libvirt-lxc-api.xml"); - - - # Some special things which aren't public APIs, -@@ -206,6 +136,8 @@ $apis{virDomainMigrateConfirm3Params}->{vers} = "1.1.0"; - # and driver struct fields. This lets us later match - # update the driver impls with the public APis. - -+my $line; -+ - # Group name -> hash of APIs { fields -> api name } - my %groups; - my $ingrp; --- -2.9.2 - diff --git a/SOURCES/libvirt-hvsupport-construct-the-group-regex-upfront.patch b/SOURCES/libvirt-hvsupport-construct-the-group-regex-upfront.patch deleted file mode 100644 index c64ab56..0000000 --- a/SOURCES/libvirt-hvsupport-construct-the-group-regex-upfront.patch +++ /dev/null @@ -1,83 +0,0 @@ -From 68a5716a222f4fc8b4d8a1568a6c83cf75b860d7 Mon Sep 17 00:00:00 2001 -Message-Id: <68a5716a222f4fc8b4d8a1568a6c83cf75b860d7@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Tue, 28 Jun 2016 15:16:01 +0200 -Subject: [PATCH] hvsupport: construct the group regex upfront -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -The %groups hash contains all the driver types (e.g. -virHypervisorDriver or virSecretDriver). - -When searching for all the APIs that are implemented by a driver -of that specific driver type, we keep iterating over the %groups -hash on every line we look at, then matching against the driver type. - -This is inefficient because it prevents perl from caching the regex -and it executes the regex once for every driver type, even though -one regex matching excludes all the others, since all the driver types -are different. - -Construct the regex containing all the driver types upfront to save -about 6.4s (~98%) of the script execution time. - -(cherry picked from commit 6dc1f103471518a7f7e2fefaf8f631eb6f2ca922) - -https://bugzilla.redhat.com/show_bug.cgi?id=1286679 -Signed-off-by: Jiri Denemark ---- - docs/hvsupport.pl | 31 +++++++++++++++---------------- - 1 file changed, 15 insertions(+), 16 deletions(-) - -diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl -index 7dd7c3f..fca83ca 100755 ---- a/docs/hvsupport.pl -+++ b/docs/hvsupport.pl -@@ -207,28 +207,27 @@ foreach my $src (@srcs) { - open FILE, "<$src" or - die "cannot read $src: $!"; - -+ my $groups_regex = join("|", keys %groups); - $ingrp = undef; - my $impl; - while (defined($line = )) { - if (!$ingrp) { -- foreach my $grp (keys %groups) { -- if ($line =~ /^\s*(?:static\s+)?$grp\s+(\w+)\s*=\s*{/ || -- $line =~ /^\s*(?:static\s+)?$grp\s+NAME\(\w+\)\s*=\s*{/) { -- $ingrp = $grp; -- $impl = $src; -+ if ($line =~ /^\s*(?:static\s+)?($groups_regex)\s+(\w+)\s*=\s*{/ || -+ $line =~ /^\s*(?:static\s+)?($groups_regex)\s+NAME\(\w+\)\s*=\s*{/) { -+ $ingrp = $1; -+ $impl = $src; - -- if ($impl =~ m,.*/node_device_(\w+)\.c,) { -- $impl = $1; -- } else { -- $impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,; -- } -- -- if ($groups{$ingrp}->{drivers}->{$impl}) { -- die "Group $ingrp already contains $impl"; -- } -- -- $groups{$ingrp}->{drivers}->{$impl} = {}; -+ if ($impl =~ m,.*/node_device_(\w+)\.c,) { -+ $impl = $1; -+ } else { -+ $impl =~ s,.*/(\w+?)_((\w+)_)?(\w+)\.c,$1,; - } -+ -+ if ($groups{$ingrp}->{drivers}->{$impl}) { -+ die "Group $ingrp already contains $impl"; -+ } -+ -+ $groups{$ingrp}->{drivers}->{$impl} = {}; - } - - } else { --- -2.9.2 - diff --git a/SOURCES/libvirt-hvsupport-skip-non-matching-lines-early.patch b/SOURCES/libvirt-hvsupport-skip-non-matching-lines-early.patch deleted file mode 100644 index 4ca57b8..0000000 --- a/SOURCES/libvirt-hvsupport-skip-non-matching-lines-early.patch +++ /dev/null @@ -1,38 +0,0 @@ -From de0ffc327adf837d9daf7577421f9d50bf754077 Mon Sep 17 00:00:00 2001 -Message-Id: -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Tue, 28 Jun 2016 15:23:58 +0200 -Subject: [PATCH] hvsupport: skip non-matching lines early - -Most of the lines we look at are not going to match one of the -driver types contained in $groups_regex. - -Move on to the next line if it does not contain any of them early. -This speeds up the script execution by 50%, since this simple regex -does not have any capture groups. - -(cherry picked from commit f1bbf57caddaddeea1141bfab9699a709aa303eb) - -https://bugzilla.redhat.com/show_bug.cgi?id=1286679 -Signed-off-by: Jiri Denemark ---- - docs/hvsupport.pl | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl -index fca83ca..2ead2cf 100755 ---- a/docs/hvsupport.pl -+++ b/docs/hvsupport.pl -@@ -212,6 +212,9 @@ foreach my $src (@srcs) { - my $impl; - while (defined($line = )) { - if (!$ingrp) { -+ # skip non-matching lines early to save time -+ next if not $line =~ /$groups_regex/; -+ - if ($line =~ /^\s*(?:static\s+)?($groups_regex)\s+(\w+)\s*=\s*{/ || - $line =~ /^\s*(?:static\s+)?($groups_regex)\s+NAME\(\w+\)\s*=\s*{/) { - $ingrp = $1; --- -2.9.2 - diff --git a/SOURCES/libvirt-hvsupport-use-a-regex-instead-of-XML-XPath.patch b/SOURCES/libvirt-hvsupport-use-a-regex-instead-of-XML-XPath.patch deleted file mode 100644 index f84acf5..0000000 --- a/SOURCES/libvirt-hvsupport-use-a-regex-instead-of-XML-XPath.patch +++ /dev/null @@ -1,113 +0,0 @@ -From 9c4286543a884891a4abcf448d07927fbbc7b9e4 Mon Sep 17 00:00:00 2001 -Message-Id: <9c4286543a884891a4abcf448d07927fbbc7b9e4@dist-git> -From: =?UTF-8?q?J=C3=A1n=20Tomko?= -Date: Tue, 28 Jun 2016 13:28:48 +0200 -Subject: [PATCH] hvsupport: use a regex instead of XML::XPath - -When generating the hvsupport.html.in file, we parse the -api.xml -files generated by apibuild.py to know in which HTML file the API -function is. - -Doing an XPath query for every single 'function' element in the -file is inefficient. - -Since the XML file is generated by another of our build scripts -(apibuild.py, using Python's standard 'output.write' XML library), -just find the function name->file mapping by a regex upfront. - -Also add a note about this next to the line that generates it -in apibuild.py and do not check if XML::XPath is installed in -bootstrap since we no longer use it. - -(cherry picked from commit ad9e72f5fa118d97abe60a0ea6e5dba195476fc7) - -https://bugzilla.redhat.com/show_bug.cgi?id=1286679 -Signed-off-by: Jiri Denemark ---- - bootstrap.conf | 1 - - docs/apibuild.py | 1 + - docs/hvsupport.pl | 33 ++++++++++++++++++++++++++++----- - 3 files changed, 29 insertions(+), 6 deletions(-) - -diff --git a/docs/apibuild.py b/docs/apibuild.py -index f5216ea..8728b27 100755 ---- a/docs/apibuild.py -+++ b/docs/apibuild.py -@@ -2267,6 +2267,7 @@ class docBuilder: - if name == debugsym and not quiet: - print "=>", id - -+ # NB: this is consumed by a regex in 'getAPIFilenames' in hvsupport.pl - output.write(" <%s name='%s' file='%s' module='%s'>\n" % (id.type, - name, self.modulename_file(id.header), - self.modulename_file(id.module))) -diff --git a/docs/hvsupport.pl b/docs/hvsupport.pl -index 7a6f1ac..7dd7c3f 100755 ---- a/docs/hvsupport.pl -+++ b/docs/hvsupport.pl -@@ -4,8 +4,6 @@ use strict; - use warnings; - - use File::Find; --use XML::XPath; --use XML::XPath::XMLParser; - - die "syntax: $0 SRCDIR\n" unless int(@ARGV) == 1; - -@@ -45,6 +43,32 @@ find({ - } - }, no_chdir => 1}, $srcdir); - -+# Map API functions to the header and documentation files they're in -+# so that we can generate proper hyperlinks to their documentation. -+# -+# The function names are grep'd from the XML output of apibuild.py. -+sub getAPIFilenames { -+ my $filename = shift; -+ -+ my %files; -+ my $line; -+ -+ open FILE, "<", $filename or die "cannot read $filename: $!"; -+ -+ while (defined($line = )) { -+ if ($line =~ /function name='([^']+)' file='([^']+)'/) { -+ $files{$1} = $2; -+ } -+ } -+ -+ close FILE; -+ -+ if (keys %files == 0) { -+ die "No functions found in $filename. Has the apibuild.py output changed?"; -+ } -+ return \%files; -+} -+ - sub parseSymsFile { - my $apisref = shift; - my $prefix = shift; -@@ -55,7 +79,7 @@ sub parseSymsFile { - my $vers; - my $prevvers; - -- my $apixpath = XML::XPath->new(filename => $xmlfilename); -+ my $filenames = getAPIFilenames($xmlfilename); - - open FILE, "<$filename" - or die "cannot read $filename: $!"; -@@ -83,10 +107,9 @@ sub parseSymsFile { - $prevvers = $vers; - $vers = undef; - } elsif ($line =~ /\s*(\w+)\s*;\s*$/) { -- my $file = $apixpath->find("/api/symbols/function[\@name='$1']/\@file"); - $$apisref{$1} = {}; - $$apisref{$1}->{vers} = $vers; -- $$apisref{$1}->{file} = $file; -+ $$apisref{$1}->{file} = $$filenames{$1}; - } else { - die "unexpected data $line\n"; - } --- -2.9.2 - diff --git a/SOURCES/libvirt-internal-Introduce-macro-for-stealing-pointers.patch b/SOURCES/libvirt-internal-Introduce-macro-for-stealing-pointers.patch deleted file mode 100644 index d5bdf6d..0000000 --- a/SOURCES/libvirt-internal-Introduce-macro-for-stealing-pointers.patch +++ /dev/null @@ -1,43 +0,0 @@ -From 42a6d5d30c4f9cca3913996f6cccf6dd383a3fd3 Mon Sep 17 00:00:00 2001 -Message-Id: <42a6d5d30c4f9cca3913996f6cccf6dd383a3fd3@dist-git> -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:11:10 -0400 -Subject: [PATCH] internal: Introduce macro for stealing pointers - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -VIR_STEAL_PTR copies the pointer from the second argument into the -first argument and then sets the second to NULL. - -(cherry picked from commit 5b7dedc995a6b33a7be33a67290155627a133a7f) ---- - src/internal.h | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/src/internal.h b/src/internal.h -index 0dc34c7..d8cc5ad 100644 ---- a/src/internal.h -+++ b/src/internal.h -@@ -307,6 +307,18 @@ - } while (0) - - /** -+ * VIR_STEAL_PTR: -+ * -+ * Steals pointer passed as second argument into the first argument. Second -+ * argument must not have side effects. -+ */ -+# define VIR_STEAL_PTR(a, b) \ -+ do { \ -+ (a) = (b); \ -+ (b) = NULL; \ -+ } while (0) -+ -+/** - * virCheckFlags: - * @supported: an OR'ed set of supported flags - * @retval: return value in case unsupported flags were passed --- -2.10.0 - diff --git a/SOURCES/libvirt-iscsi-Establish-connection-to-target-via-static-target-login.patch b/SOURCES/libvirt-iscsi-Establish-connection-to-target-via-static-target-login.patch deleted file mode 100644 index 6bbc8b7..0000000 --- a/SOURCES/libvirt-iscsi-Establish-connection-to-target-via-static-target-login.patch +++ /dev/null @@ -1,44 +0,0 @@ -From c81a60b88a477a2fb8a35e53b6e4da3a6029dfd0 Mon Sep 17 00:00:00 2001 -Message-Id: -From: John Ferlan -Date: Mon, 1 Aug 2016 13:31:53 -0400 -Subject: [PATCH] iscsi: Establish connection to target via static target login - -https://bugzilla.redhat.com/show_bug.cgi?id=1356436 - -Commit id '56057900' altered the discovery of iSCSI node targets by -using the "--op nonpersistent". This caused issues for clean environments -or if by chance a "-m node -o delete" was executed. - -Since each iSCSI Storage Pool has the required iSCSI target path, use -that and the virISCSINodeNew API in order to generate the iSCSI node record. - -(cherry picked from commit 5d8c31c6b202aa5ce4329042225bb40fec16baf9) -Signed-off-by: John Ferlan ---- - src/storage/storage_backend_iscsi.c | 9 ++++----- - 1 file changed, 4 insertions(+), 5 deletions(-) - -diff --git a/src/storage/storage_backend_iscsi.c b/src/storage/storage_backend_iscsi.c -index bb33da2..84ad6f3 100644 ---- a/src/storage/storage_backend_iscsi.c -+++ b/src/storage/storage_backend_iscsi.c -@@ -353,11 +353,10 @@ virStorageBackendISCSIStartPool(virConnectPtr conn, - if ((session = virStorageBackendISCSISession(pool, true)) == NULL) { - if ((portal = virStorageBackendISCSIPortal(&pool->def->source)) == NULL) - goto cleanup; -- /* -- * iscsiadm doesn't let you login to a target, unless you've -- * first issued a 'sendtargets' command to the portal :-( -- */ -- if (virISCSIScanTargets(portal, NULL, NULL) < 0) -+ -+ /* Create a static node record for the IQN target. Must be done -+ * in order for login to the target */ -+ if (virISCSINodeNew(portal, pool->def->source.devices[0].path) < 0) - goto cleanup; - - if (virStorageBackendISCSISetAuth(portal, conn, &pool->def->source) < 0) --- -2.9.2 - diff --git a/SOURCES/libvirt-libvirt-convert-to-typesafe-virConf-accessors.patch b/SOURCES/libvirt-libvirt-convert-to-typesafe-virConf-accessors.patch deleted file mode 100644 index ff85989..0000000 --- a/SOURCES/libvirt-libvirt-convert-to-typesafe-virConf-accessors.patch +++ /dev/null @@ -1,291 +0,0 @@ -From c70fe441c47030833541ec9401c9b6729bdae2fe Mon Sep 17 00:00:00 2001 -Message-Id: -From: "Daniel P. Berrange" -Date: Tue, 16 Aug 2016 13:06:02 +0200 -Subject: [PATCH] libvirt: convert to typesafe virConf accessors - -Signed-off-by: Daniel P. Berrange -(cherry picked from commit f5da0d18053376cc2a80e4648c68840b801cba81) - -Although the upstream commit applied to downstream cleanly, it had to be -further modified in the way how it retrieves data from our config structure. -The original commit relied on some new accessors (wrappers) added by 6381c89f -which however was not backported. Therefore the old way of retrieving data from -the config structure by virConfGetValue had to be used. - -https://bugzilla.redhat.com/show_bug.cgi?id=1367269 -Signed-off-by: Erik Skultety ---- - src/libvirt-admin.c | 74 +++++++++++++++++++++++++++++++------------------- - src/libvirt.c | 78 +++++++++++++++++++++++++++++++++-------------------- - 2 files changed, 96 insertions(+), 56 deletions(-) - -diff --git a/src/libvirt-admin.c b/src/libvirt-admin.c -index f07cb10..c485752 100644 ---- a/src/libvirt-admin.c -+++ b/src/libvirt-admin.c -@@ -158,35 +158,44 @@ getSocketPath(virURIPtr uri) - goto cleanup; - } - --static const char * --virAdmGetDefaultURI(virConfPtr conf) -+static int -+virAdmGetDefaultURI(virConfPtr conf, char **uristr) - { - virConfValuePtr value = NULL; -- const char *uristr = NULL; -+ const char *defname = virGetEnvAllowSUID("LIBVIRT_ADMIN_DEFAULT_URI"); - -- uristr = virGetEnvAllowSUID("LIBVIRT_ADMIN_DEFAULT_URI"); -- if (uristr && *uristr) { -- VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", uristr); -- } else if ((value = virConfGetValue(conf, "admin_uri_default"))) { -- if (value->type != VIR_CONF_STRING) { -- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", -- _("Expected a string for 'admin_uri_default' config " -- "parameter")); -- return NULL; -+ if (defname && *defname) { -+ if (VIR_STRDUP(*uristr, defname) < 0) -+ return -1; -+ VIR_DEBUG("Using LIBVIRT_ADMIN_DEFAULT_URI '%s'", *uristr); -+ } else { -+ if ((value = virConfGetValue(conf, "admin_uri_default"))) { -+ if (value->type != VIR_CONF_STRING) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", -+ _("Expected a string for 'admin_uri_default' " -+ "config parameter")); -+ return -1; -+ } -+ -+ VIR_FREE(*uristr); -+ if (VIR_STRDUP(*uristr, value->str) < 0) -+ return -1; - } - -- VIR_DEBUG("Using config file uri '%s'", value->str); -- uristr = value->str; -- } else { -- /* Since we can't probe connecting via any hypervisor driver as libvirt -- * does, if no explicit URI was given and neither the environment -- * variable, nor the configuration parameter had previously been set, -- * we set the default admin server URI to 'libvirtd://system'. -- */ -- uristr = "libvirtd:///system"; -+ if (*uristr) { -+ VIR_DEBUG("Using config file uri '%s'", *uristr); -+ } else { -+ /* Since we can't probe connecting via any hypervisor driver as libvirt -+ * does, if no explicit URI was given and neither the environment -+ * variable, nor the configuration parameter had previously been set, -+ * we set the default admin server URI to 'libvirtd://system'. -+ */ -+ if (VIR_STRDUP(*uristr, "libvirtd:///system") < 0) -+ return -1; -+ } - } - -- return uristr; -+ return 0; - } - - /** -@@ -206,6 +215,7 @@ virAdmConnectOpen(const char *name, unsigned int flags) - char *alias = NULL; - virAdmConnectPtr conn = NULL; - virConfPtr conf = NULL; -+ char *uristr = NULL; - - if (virAdmInitialize() < 0) - goto error; -@@ -219,14 +229,24 @@ virAdmConnectOpen(const char *name, unsigned int flags) - if (virConfLoadConfig(&conf, "libvirt-admin.conf") < 0) - goto error; - -- if (!name && !(name = virAdmGetDefaultURI(conf))) -- goto error; -+ if (name) { -+ if (VIR_STRDUP(uristr, name) < 0) -+ goto error; -+ } else { -+ if (virAdmGetDefaultURI(conf, &uristr) < 0) -+ goto error; -+ } - - if ((!(flags & VIR_CONNECT_NO_ALIASES) && -- virURIResolveAlias(conf, name, &alias) < 0)) -+ virURIResolveAlias(conf, uristr, &alias) < 0)) - goto error; - -- if (!(conn->uri = virURIParse(alias ? alias : name))) -+ if (alias) { -+ VIR_FREE(uristr); -+ uristr = alias; -+ } -+ -+ if (!(conn->uri = virURIParse(uristr))) - goto error; - - if (!(sock_path = getSocketPath(conn->uri))) -@@ -242,7 +262,7 @@ virAdmConnectOpen(const char *name, unsigned int flags) - - cleanup: - VIR_FREE(sock_path); -- VIR_FREE(alias); -+ VIR_FREE(uristr); - virConfFree(conf); - return conn; - -diff --git a/src/libvirt.c b/src/libvirt.c -index f26eec4..215701f 100644 ---- a/src/libvirt.c -+++ b/src/libvirt.c -@@ -903,22 +903,32 @@ virGetVersion(unsigned long *libVer, const char *type ATTRIBUTE_UNUSED, - - static int - virConnectGetDefaultURI(virConfPtr conf, -- const char **name) -+ char **name) - { - int ret = -1; - virConfValuePtr value = NULL; - const char *defname = virGetEnvBlockSUID("LIBVIRT_DEFAULT_URI"); -+ - if (defname && *defname) { - VIR_DEBUG("Using LIBVIRT_DEFAULT_URI '%s'", defname); -- *name = defname; -- } else if ((value = virConfGetValue(conf, "uri_default"))) { -- if (value->type != VIR_CONF_STRING) { -- virReportError(VIR_ERR_INTERNAL_ERROR, "%s", -- _("Expected a string for 'uri_default' config parameter")); -+ if (VIR_STRDUP(*name, defname) < 0) - goto cleanup; -+ } else { -+ if ((value = virConfGetValue(conf, "uri_default"))) { -+ if (value->type != VIR_CONF_STRING) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", -+ _("Expected a string for 'uri_default' config " -+ "parameter")); -+ goto cleanup; -+ } -+ -+ VIR_FREE(*name); -+ if (VIR_STRDUP(*name, value->str) < 0) -+ goto cleanup; - } -- VIR_DEBUG("Using config file uri '%s'", value->str); -- *name = value->str; -+ -+ if (*name) -+ VIR_DEBUG("Using config file uri '%s'", *name); - } - - ret = 0; -@@ -965,6 +975,7 @@ virConnectOpenInternal(const char *name, - int res; - virConnectPtr ret; - virConfPtr conf = NULL; -+ char *uristr = NULL; - - ret = virGetConnect(); - if (ret == NULL) -@@ -982,54 +993,61 @@ virConnectOpenInternal(const char *name, - goto failed; - } - -+ /* Convert xen -> xen:/// for back compat */ -+ if (name && STRCASEEQ(name, "xen")) -+ name = "xen:///"; -+ -+ /* Convert xen:// -> xen:/// because xmlParseURI cannot parse the -+ * former. This allows URIs such as xen://localhost to work. -+ */ -+ if (name && STREQ(name, "xen://")) -+ name = "xen:///"; -+ - /* - * If no URI is passed, then check for an environment string if not - * available probe the compiled in drivers to find a default hypervisor - * if detectable. - */ -- if (!name && -- virConnectGetDefaultURI(conf, &name) < 0) -- goto failed; -- - if (name) { -- char *alias = NULL; -- /* Convert xen -> xen:/// for back compat */ -- if (STRCASEEQ(name, "xen")) -- name = "xen:///"; -+ if (VIR_STRDUP(uristr, name) < 0) -+ goto failed; -+ } else { -+ if (virConnectGetDefaultURI(conf, &uristr) < 0) -+ goto failed; -+ } - -- /* Convert xen:// -> xen:/// because xmlParseURI cannot parse the -- * former. This allows URIs such as xen://localhost to work. -- */ -- if (STREQ(name, "xen://")) -- name = "xen:///"; -+ if (uristr) { -+ char *alias = NULL; - - if (!(flags & VIR_CONNECT_NO_ALIASES) && -- virURIResolveAlias(conf, name, &alias) < 0) -+ virURIResolveAlias(conf, uristr, &alias) < 0) - goto failed; - -- if (!(ret->uri = virURIParse(alias ? alias : name))) { -+ if (alias) { -+ VIR_FREE(uristr); -+ uristr = alias; -+ } -+ -+ if (!(ret->uri = virURIParse(uristr))) { - VIR_FREE(alias); - goto failed; - } - -- VIR_DEBUG("name \"%s\" to URI components:\n" -+ VIR_DEBUG("Split \"%s\" to URI components:\n" - " scheme %s\n" - " server %s\n" - " user %s\n" - " port %d\n" - " path %s", -- alias ? alias : name, -+ uristr, - NULLSTR(ret->uri->scheme), NULLSTR(ret->uri->server), - NULLSTR(ret->uri->user), ret->uri->port, - NULLSTR(ret->uri->path)); - -- if (virConnectCheckURIMissingSlash(alias ? alias : name, -+ if (virConnectCheckURIMissingSlash(uristr, - ret->uri) < 0) { -- VIR_FREE(alias); - goto failed; - } -- -- VIR_FREE(alias); - } else { - VIR_DEBUG("no name, allowing driver auto-select"); - } -@@ -1114,10 +1132,12 @@ virConnectOpenInternal(const char *name, - } - - virConfFree(conf); -+ VIR_FREE(uristr); - - return ret; - - failed: -+ VIR_FREE(uristr); - virConfFree(conf); - virObjectUnref(ret); - --- -2.9.2 - diff --git a/SOURCES/libvirt-locking-Add-support-for-sanlock_strerror.patch b/SOURCES/libvirt-locking-Add-support-for-sanlock_strerror.patch new file mode 100644 index 0000000..1d51b32 --- /dev/null +++ b/SOURCES/libvirt-locking-Add-support-for-sanlock_strerror.patch @@ -0,0 +1,339 @@ +From 6744458379e73967a95507d3c0b91b52a62fc3ec Mon Sep 17 00:00:00 2001 +Message-Id: <6744458379e73967a95507d3c0b91b52a62fc3ec@dist-git> +From: Jiri Denemark +Date: Thu, 27 Apr 2017 11:54:44 +0200 +Subject: [PATCH] locking: Add support for sanlock_strerror + +The recently added sanlock_strerror function can be used to translate +sanlock's numeric errors into human readable strings. + +https://bugzilla.redhat.com/show_bug.cgi?id=1409511 + +Signed-off-by: Jiri Denemark +(cherry picked from commit 23377c539b72a7fc4e2749a068711fe1f626998d) +Signed-off-by: Jiri Denemark +--- + m4/virt-sanlock.m4 | 7 ++ + src/locking/lock_driver_sanlock.c | 154 ++++++++++++++++++++++++++------------ + 2 files changed, 115 insertions(+), 46 deletions(-) + +diff --git a/m4/virt-sanlock.m4 b/m4/virt-sanlock.m4 +index e4476cae4..00de7980e 100644 +--- a/m4/virt-sanlock.m4 ++++ b/m4/virt-sanlock.m4 +@@ -61,6 +61,13 @@ AC_DEFUN([LIBVIRT_CHECK_SANLOCK],[ + [whether sanlock supports sanlock_write_lockspace]) + fi + ++ AC_CHECK_LIB([sanlock_client], [sanlock_strerror], ++ [sanlock_strerror=yes], [sanlock_strerror=no]) ++ if test "x$sanlock_strerror" = "xyes" ; then ++ AC_DEFINE_UNQUOTED([HAVE_SANLOCK_STRERROR], 1, ++ [whether sanlock supports sanlock_strerror]) ++ fi ++ + CPPFLAGS="$old_cppflags" + LIBS="$old_libs" + fi +diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c +index 280219f72..b5e69c472 100644 +--- a/src/locking/lock_driver_sanlock.c ++++ b/src/locking/lock_driver_sanlock.c +@@ -97,6 +97,25 @@ struct _virLockManagerSanlockPrivate { + bool registered; + }; + ++ ++static bool ++ATTRIBUTE_NONNULL(2) ++virLockManagerSanlockError(int err, ++ char **message) ++{ ++ if (err <= -200) { ++#if HAVE_SANLOCK_STRERROR ++ ignore_value(VIR_STRDUP_QUIET(*message, sanlock_strerror(err))); ++#else ++ ignore_value(virAsprintfQuiet(message, _("sanlock error %d"), err)); ++#endif ++ return true; ++ } else { ++ return false; ++ } ++} ++ ++ + /* + * sanlock plugin for the libvirt virLockManager API + */ +@@ -263,14 +282,17 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver) + } + + if ((rv = sanlock_align(&ls.host_id_disk)) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Unable to query sector size %s: error %d"), +- path, rv); +- else ++ _("Unable to query sector size %s: %s"), ++ path, NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, + _("Unable to query sector size %s"), + path); ++ } + goto error_unlink; + } + +@@ -292,14 +314,17 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver) + } + + if ((rv = virLockManagerSanlockInitLockspace(driver, &ls) < 0)) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Unable to initialize lockspace %s: error %d"), +- path, rv); +- else ++ _("Unable to initialize lockspace %s: %s"), ++ path, NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, + _("Unable to initialize lockspace %s"), + path); ++ } + goto error_unlink; + } + VIR_DEBUG("Lockspace %s has been initialized", path); +@@ -362,14 +387,17 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver) + goto retry; + } + if (-rv != EEXIST) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Unable to add lockspace %s: error %d"), +- path, rv); +- else ++ _("Unable to add lockspace %s: %s"), ++ path, NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, + _("Unable to add lockspace %s"), + path); ++ } + goto error; + } else { + VIR_DEBUG("Lockspace %s is already registered", path); +@@ -694,14 +722,17 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriverPtr driver, + } + + if ((rv = sanlock_align(&res->disks[0])) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Unable to query sector size %s: error %d"), +- res->disks[0].path, rv); +- else ++ _("Unable to query sector size %s: %s"), ++ res->disks[0].path, NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, + _("Unable to query sector size %s"), + res->disks[0].path); ++ } + goto error_unlink; + } + +@@ -723,14 +754,17 @@ virLockManagerSanlockCreateLease(virLockManagerSanlockDriverPtr driver, + } + + if ((rv = sanlock_init(NULL, res, 0, 0)) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Unable to initialize lease %s: error %d"), +- res->disks[0].path, rv); +- else ++ _("Unable to initialize lease %s: %s"), ++ res->disks[0].path, NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, + _("Unable to initialize lease %s"), + res->disks[0].path); ++ } + goto error_unlink; + } + VIR_DEBUG("Lease %s has been initialized", res->disks[0].path); +@@ -867,10 +901,12 @@ virLockManagerSanlockRegisterKillscript(int sock, + } + + if ((rv = sanlock_killpath(sock, 0, path, args)) < 0) { +- if (rv <= -200) { ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Failed to register lock failure action:" +- " error %d"), rv); ++ _("Failed to register lock failure action: %s"), ++ NULLSTR(err)); ++ VIR_FREE(err); + } else { + virReportSystemError(-rv, "%s", + _("Failed to register lock failure" +@@ -934,13 +970,16 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock, + if (priv->vm_pid == getpid()) { + VIR_DEBUG("Register sanlock %d", flags); + if ((sock = sanlock_register()) < 0) { +- if (sock <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(sock, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Failed to open socket to sanlock daemon: error %d"), +- sock); +- else ++ _("Failed to open socket to sanlock daemon: %s"), ++ NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-sock, "%s", + _("Failed to open socket to sanlock daemon")); ++ } + goto error; + } + +@@ -971,14 +1010,17 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock, + if ((rv = sanlock_state_to_args((char *)state, + &res_count, + &res_args)) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Unable to parse lock state %s: error %d"), +- state, rv); +- else ++ _("Unable to parse lock state %s: %s"), ++ state, NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, + _("Unable to parse lock state %s"), + state); ++ } + goto error; + } + res_free = true; +@@ -992,12 +1034,16 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock, + if ((rv = sanlock_acquire(sock, priv->vm_pid, 0, + priv->res_count, priv->res_args, + opt)) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_RESOURCE_BUSY, +- _("Failed to acquire lock: error %d"), rv); +- else ++ _("Failed to acquire lock: %s"), ++ NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, "%s", + _("Failed to acquire lock")); ++ } + goto error; + } + } +@@ -1016,12 +1062,16 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock, + + if (flags & VIR_LOCK_MANAGER_ACQUIRE_RESTRICT) { + if ((rv = sanlock_restrict(sock, SANLK_RESTRICT_ALL)) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Failed to restrict process: error %d"), rv); +- else ++ _("Failed to restrict process: %s"), ++ NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, "%s", + _("Failed to restrict process")); ++ } + goto error; + } + } +@@ -1068,12 +1118,16 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock, + + if (state) { + if ((rv = sanlock_inquire(-1, priv->vm_pid, 0, &res_count, state)) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Failed to inquire lock: error %d"), rv); +- else ++ _("Failed to inquire lock: %s"), ++ NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, "%s", + _("Failed to inquire lock")); ++ } + return -1; + } + +@@ -1083,12 +1137,16 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock, + + if ((rv = sanlock_release(-1, priv->vm_pid, 0, res_count, + priv->res_args)) < 0) { +- if (rv <= -200) ++ char *err = NULL; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Failed to release lock: error %d"), rv); +- else ++ _("Failed to release lock: %s"), ++ NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, "%s", + _("Failed to release lock")); ++ } + return -1; + } + +@@ -1118,12 +1176,16 @@ static int virLockManagerSanlockInquire(virLockManagerPtr lock, + } + + if ((rv = sanlock_inquire(-1, priv->vm_pid, 0, &res_count, state)) < 0) { +- if (rv <= -200) ++ char *err; ++ if (virLockManagerSanlockError(rv, &err)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Failed to inquire lock: error %d"), rv); +- else ++ _("Failed to inquire lock: %s"), ++ NULLSTR(err)); ++ VIR_FREE(err); ++ } else { + virReportSystemError(-rv, "%s", + _("Failed to inquire lock")); ++ } + return -1; + } + +-- +2.12.2 + diff --git a/SOURCES/libvirt-logical-Increase-the-size-of-the-data-to-wipe.patch b/SOURCES/libvirt-logical-Increase-the-size-of-the-data-to-wipe.patch new file mode 100644 index 0000000..87be249 --- /dev/null +++ b/SOURCES/libvirt-logical-Increase-the-size-of-the-data-to-wipe.patch @@ -0,0 +1,35 @@ +From f4b39613c3c345e33fa749911f34127cf91c07fc Mon Sep 17 00:00:00 2001 +Message-Id: +From: John Ferlan +Date: Wed, 26 Apr 2017 08:41:13 -0400 +Subject: [PATCH] logical: Increase the size of the data to wipe + +https://bugzilla.redhat.com/show_bug.cgi?id=1439132 +https://bugzilla.redhat.com/show_bug.cgi?id=1373711 + +Since a sector size may be larger than 512 bytes, let's just increase +the size to wipe to 1MB rather than 2KB + +(cherry picked from commit d942bf6e9e8e3991808ca5185098257e84acab5d) +Signed-off-by: John Ferlan +Signed-off-by: Jiri Denemark +--- + src/storage/storage_backend_logical.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c +index a8650368b..ed26c2450 100644 +--- a/src/storage/storage_backend_logical.c ++++ b/src/storage/storage_backend_logical.c +@@ -100,7 +100,7 @@ virStorageBackendLogicalInitializeDevice(const char *path) + * a whole disk as a PV. So we just blank them out regardless + * rather than trying to figure out if we're a disk or partition + */ +- if (virStorageBackendZeroPartitionTable(path, 4 * PV_BLANK_SECTOR_SIZE) < 0) ++ if (virStorageBackendZeroPartitionTable(path, 1024 * 1024) < 0) + return -1; + + /* +-- +2.12.2 + diff --git a/SOURCES/libvirt-logical-Use-virStorageBackendZeroPartitionTable.patch b/SOURCES/libvirt-logical-Use-virStorageBackendZeroPartitionTable.patch new file mode 100644 index 0000000..78c876e --- /dev/null +++ b/SOURCES/libvirt-logical-Use-virStorageBackendZeroPartitionTable.patch @@ -0,0 +1,92 @@ +From 0ea93040c8172ff8848b6295e53b7bd26f66ef05 Mon Sep 17 00:00:00 2001 +Message-Id: <0ea93040c8172ff8848b6295e53b7bd26f66ef05@dist-git> +From: John Ferlan +Date: Wed, 26 Apr 2017 08:41:12 -0400 +Subject: [PATCH] logical: Use virStorageBackendZeroPartitionTable + +https://bugzilla.redhat.com/show_bug.cgi?id=1439132 +https://bugzilla.redhat.com/show_bug.cgi?id=1373711 + +Rather than open code it, use the new function which uses the wipe algorithm +in order to zero the front and tail of the partition. + +(cherry picked from commit c6aa81c65abe3f327af870d5789a98a0c9b276d1) +Signed-off-by: John Ferlan +Signed-off-by: Jiri Denemark +--- + src/storage/storage_backend_logical.c | 44 +---------------------------------- + 1 file changed, 1 insertion(+), 43 deletions(-) + +diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c +index d87aaf0b6..a8650368b 100644 +--- a/src/storage/storage_backend_logical.c ++++ b/src/storage/storage_backend_logical.c +@@ -92,9 +92,6 @@ virStorageBackendLogicalRemoveDevice(const char *path) + static int + virStorageBackendLogicalInitializeDevice(const char *path) + { +- int fd = -1; +- char zeros[4 * PV_BLANK_SECTOR_SIZE] = {0}; +- off_t size; + int ret = -1; + virCommandPtr pvcmd = NULL; + +@@ -103,46 +100,8 @@ virStorageBackendLogicalInitializeDevice(const char *path) + * a whole disk as a PV. So we just blank them out regardless + * rather than trying to figure out if we're a disk or partition + */ +- if ((fd = open(path, O_WRONLY)) < 0) { +- virReportSystemError(errno, _("cannot open device '%s'"), path); ++ if (virStorageBackendZeroPartitionTable(path, 4 * PV_BLANK_SECTOR_SIZE) < 0) + return -1; +- } +- +- if ((size = lseek(fd, 0, SEEK_END)) == (off_t)-1) { +- virReportSystemError(errno, +- _("failed to seek to end of %s"), path); +- goto cleanup; +- } +- +- if (size < 4 * PV_BLANK_SECTOR_SIZE) { +- virReportError(VIR_ERR_OPERATION_UNSUPPORTED, +- _("cannot initialize '%s' detected size='%zd' less " +- "than minimum required='%d"), +- path, (ssize_t) size, 4 * PV_BLANK_SECTOR_SIZE); +- goto cleanup; +- } +- if ((size = lseek(fd, 0, SEEK_SET)) == (off_t)-1) { +- virReportSystemError(errno, +- _("failed to seek to start of %s"), path); +- goto cleanup; +- } +- +- if (safewrite(fd, zeros, sizeof(zeros)) < 0) { +- virReportSystemError(errno, _("cannot clear device header of '%s'"), +- path); +- goto cleanup; +- } +- +- if (fsync(fd) < 0) { +- virReportSystemError(errno, _("cannot flush header of device'%s'"), +- path); +- goto cleanup; +- } +- +- if (VIR_CLOSE(fd) < 0) { +- virReportSystemError(errno, _("cannot close device '%s'"), path); +- goto cleanup; +- } + + /* + * Initialize the physical volume because vgcreate is not +@@ -155,7 +114,6 @@ virStorageBackendLogicalInitializeDevice(const char *path) + ret = 0; + + cleanup: +- VIR_FORCE_CLOSE(fd); + virCommandFree(pvcmd); + + return ret; +-- +2.12.2 + diff --git a/SOURCES/libvirt-lxc-Don-t-crash-by-forgetting-to-ref-transient-domains.patch b/SOURCES/libvirt-lxc-Don-t-crash-by-forgetting-to-ref-transient-domains.patch deleted file mode 100644 index 4bfefc5..0000000 --- a/SOURCES/libvirt-lxc-Don-t-crash-by-forgetting-to-ref-transient-domains.patch +++ /dev/null @@ -1,38 +0,0 @@ -From b7eb93d486c0c855e6a21c5f67ed658a52a7e8fa Mon Sep 17 00:00:00 2001 -Message-Id: -From: Martin Kletzander -Date: Sun, 24 Jul 2016 09:43:35 +0200 -Subject: [PATCH] lxc: Don't crash by forgetting to ref transient domains - -So commit 306b3a8504 tried mimicking behaviour of commit 540c339a25, but -added a virObjectRef(vm) only after virDomainObjListAdd() in -lxcDomainDefineXMLFlags() and not in lxcDomainCreateXMLWithFiles(). -That way undefining a domain that was started with different XML than -defined will leave the domain object in a state with not enough -references to then remove it. Hence any lxcDomainDestroyFlags() called -afterwards crashes the daemon. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1351057 - -Signed-off-by: Martin Kletzander -(cherry picked from commit e4200bbb9d9bbc58a51ca55c6073146126447afb) -Signed-off-by: Martin Kletzander ---- - src/lxc/lxc_driver.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c -index a3fa770..80b7a5c 100644 ---- a/src/lxc/lxc_driver.c -+++ b/src/lxc/lxc_driver.c -@@ -1249,6 +1249,7 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, - VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE, - NULL))) - goto cleanup; -+ virObjectRef(vm); - def = NULL; - - if (virLXCDomainObjBeginJob(driver, vm, LXC_JOB_MODIFY) < 0) { --- -2.9.2 - diff --git a/SOURCES/libvirt-lxcDomainCreateXMLWithFiles-Avoid-crash.patch b/SOURCES/libvirt-lxcDomainCreateXMLWithFiles-Avoid-crash.patch deleted file mode 100644 index 91def75..0000000 --- a/SOURCES/libvirt-lxcDomainCreateXMLWithFiles-Avoid-crash.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 00cc1b75dd5933bc68236ebc417fc816c4f45651 Mon Sep 17 00:00:00 2001 -Message-Id: <00cc1b75dd5933bc68236ebc417fc816c4f45651@dist-git> -From: Michal Privoznik -Date: Fri, 5 Aug 2016 16:34:37 +0200 -Subject: [PATCH] lxcDomainCreateXMLWithFiles: Avoid crash - -https://bugzilla.redhat.com/show_bug.cgi?id=1363773 - -Imagine that you're creating a transient domain, but for some reason, -starting it fails. That is virLXCProcessStart() returns an error. With -current code, in the error handling code the domain object is removed -from the domain object list, @vm is set to NULL and controls jump to -enjob label where virLXCDomainObjEndJob() is called which dereference vm -leading to instant crash. - -The fix is to end the job in the error handling code and only after that -remove the domain from the list and jump onto cleanup label instead of -endjob. - -Signed-off-by: Michal Privoznik -(cherry picked from commit 5f5a5a42e5146336430b9284539d4bff3e8bb598) -Signed-off-by: Michal Privoznik ---- - src/lxc/lxc_driver.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c -index 80b7a5c..d47f215 100644 ---- a/src/lxc/lxc_driver.c -+++ b/src/lxc/lxc_driver.c -@@ -1265,11 +1265,12 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, - (flags & VIR_DOMAIN_START_AUTODESTROY), - VIR_DOMAIN_RUNNING_BOOTED) < 0) { - virDomainAuditStart(vm, "booted", false); -+ virLXCDomainObjEndJob(driver, vm); - if (!vm->persistent) { - virDomainObjListRemove(driver->domains, vm); - vm = NULL; - } -- goto endjob; -+ goto cleanup; - } - - event = virDomainEventLifecycleNewFromObj(vm, -@@ -1281,7 +1282,6 @@ lxcDomainCreateXMLWithFiles(virConnectPtr conn, - if (dom) - dom->id = vm->def->id; - -- endjob: - virLXCDomainObjEndJob(driver, vm); - - cleanup: --- -2.9.2 - diff --git a/SOURCES/libvirt-mdev-Fix-daemon-crash-on-domain-shutdown-after-reconnect.patch b/SOURCES/libvirt-mdev-Fix-daemon-crash-on-domain-shutdown-after-reconnect.patch new file mode 100644 index 0000000..3162d40 --- /dev/null +++ b/SOURCES/libvirt-mdev-Fix-daemon-crash-on-domain-shutdown-after-reconnect.patch @@ -0,0 +1,117 @@ +From 2122aadba5eb30ae466a3e825bbe9ed75b8d9735 Mon Sep 17 00:00:00 2001 +Message-Id: <2122aadba5eb30ae466a3e825bbe9ed75b8d9735@dist-git> +From: Erik Skultety +Date: Thu, 4 May 2017 13:50:00 +0200 +Subject: [PATCH] mdev: Fix daemon crash on domain shutdown after reconnect + +The problem resides in virHostdevUpdateActiveMediatedDevices which gets +called during qemuProcessReconnect. The issue here is that +virMediatedDeviceListAdd takes a pointer to the item to be added to the +list to which VIR_APPEND_ELEMENT is used, which also clears the pointer. +However, in this case only the local copy of the pointer got cleared, +leaving the original pointing to valid memory. To sum it up, during +cleanup phase, the original pointer is freed and the daemon crashes +basically any time it would access it. + +Backtrace: +0x00007ffff3ccdeba in __strcmp_sse2_unaligned +0x00007ffff72a444a in virMediatedDeviceListFindIndex +0x00007ffff7241446 in virHostdevReAttachMediatedDevices +0x00007fffc60215d9 in qemuHostdevReAttachMediatedDevices +0x00007fffc60216dc in qemuHostdevReAttachDomainDevices +0x00007fffc6046e6f in qemuProcessStop +0x00007fffc6091596 in processMonitorEOFEvent +0x00007fffc6091793 in qemuProcessEventHandler +0x00007ffff7294bf5 in virThreadPoolWorker +0x00007ffff7294184 in virThreadHelper +0x00007ffff3fdc3c4 in start_thread () from /lib64/libpthread.so.0 +0x00007ffff3d269cf in clone () from /lib64/libc.so.6 + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1446455 + +Signed-off-by: Erik Skultety +Reviewed-by: Laine Stump +(cherry picked from commit 92e30a4dace54d06433f763e1acba0a81bb5c82e) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + src/util/virhostdev.c | 4 ++-- + src/util/virmdev.c | 13 ++++++++----- + src/util/virmdev.h | 2 +- + 3 files changed, 11 insertions(+), 8 deletions(-) + +diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c +index 2c557f5bb..579563c3f 100644 +--- a/src/util/virhostdev.c ++++ b/src/util/virhostdev.c +@@ -1294,7 +1294,7 @@ virHostdevUpdateActiveMediatedDevices(virHostdevManagerPtr mgr, + + virMediatedDeviceSetUsedBy(mdev, drv_name, dom_name); + +- if (virMediatedDeviceListAdd(mgr->activeMediatedHostdevs, mdev) < 0) ++ if (virMediatedDeviceListAdd(mgr->activeMediatedHostdevs, &mdev) < 0) + goto cleanup; + } + +@@ -1790,7 +1790,7 @@ virHostdevPrepareMediatedDevices(virHostdevManagerPtr mgr, + if (!(mdev = virMediatedDeviceNew(src->uuidstr, src->model))) + goto cleanup; + +- if (virMediatedDeviceListAdd(list, mdev) < 0) { ++ if (virMediatedDeviceListAdd(list, &mdev) < 0) { + virMediatedDeviceFree(mdev); + goto cleanup; + } +diff --git a/src/util/virmdev.c b/src/util/virmdev.c +index c1499d238..c861d21c9 100644 +--- a/src/util/virmdev.c ++++ b/src/util/virmdev.c +@@ -312,16 +312,19 @@ virMediatedDeviceListDispose(void *obj) + } + + ++/* The reason for @dev to be double pointer is that VIR_APPEND_ELEMENT clears ++ * the pointer and we need to clear the original not a copy on the stack ++ */ + int + virMediatedDeviceListAdd(virMediatedDeviceListPtr list, +- virMediatedDevicePtr dev) ++ virMediatedDevicePtr *dev) + { +- if (virMediatedDeviceListFind(list, dev)) { ++ if (virMediatedDeviceListFind(list, *dev)) { + virReportError(VIR_ERR_INTERNAL_ERROR, +- _("device %s is already in use"), dev->path); ++ _("device %s is already in use"), (*dev)->path); + return -1; + } +- return VIR_APPEND_ELEMENT(list->devs, list->count, dev); ++ return VIR_APPEND_ELEMENT(list->devs, list->count, *dev); + } + + +@@ -457,7 +460,7 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst, + * - caller is responsible for NOT freeing devices in @src on success + * - we're responsible for performing a rollback on failure + */ +- if (virMediatedDeviceListAdd(dst, mdev) < 0) ++ if (virMediatedDeviceListAdd(dst, &mdev) < 0) + goto rollback; + + VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'", +diff --git a/src/util/virmdev.h b/src/util/virmdev.h +index 2f3d6bb84..8bb46b9c5 100644 +--- a/src/util/virmdev.h ++++ b/src/util/virmdev.h +@@ -86,7 +86,7 @@ virMediatedDeviceListNew(void); + + int + virMediatedDeviceListAdd(virMediatedDeviceListPtr list, +- virMediatedDevicePtr dev); ++ virMediatedDevicePtr *dev); + + virMediatedDevicePtr + virMediatedDeviceListGet(virMediatedDeviceListPtr list, +-- +2.13.0 + diff --git a/SOURCES/libvirt-mdev-Pass-a-uuidstr-rather-than-an-mdev-object-to-some-util-functions.patch b/SOURCES/libvirt-mdev-Pass-a-uuidstr-rather-than-an-mdev-object-to-some-util-functions.patch new file mode 100644 index 0000000..1f4d74a --- /dev/null +++ b/SOURCES/libvirt-mdev-Pass-a-uuidstr-rather-than-an-mdev-object-to-some-util-functions.patch @@ -0,0 +1,269 @@ +From ebb336d5b22b9707b53bcc4fd2e24845666fdc4f Mon Sep 17 00:00:00 2001 +Message-Id: +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:50 +0200 +Subject: [PATCH] mdev: Pass a uuidstr rather than an mdev object to some util + functions + +Namely, this patch is about virMediatedDeviceGetIOMMUGroup{Dev,Num} +functions. There's no compelling reason why these functions should take +an object, on the contrary, having to create an object every time one +needs to query the IOMMU group number, discarding the object afterwards, +seems odd. + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit 3a2a2a7401d06a8f06fa75359190f59737c5dc5d) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_domain.c | 8 +------- + src/security/security_apparmor.c | 10 +--------- + src/security/security_dac.c | 20 ++------------------ + src/security/security_selinux.c | 20 ++------------------ + src/util/virmdev.c | 21 +++++++++++++-------- + src/util/virmdev.h | 4 ++-- + 6 files changed, 21 insertions(+), 62 deletions(-) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index 117c6142b..04d1b39db 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -7216,7 +7216,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, + virUSBDevicePtr usb = NULL; + virSCSIDevicePtr scsi = NULL; + virSCSIVHostDevicePtr host = NULL; +- virMediatedDevicePtr mdev = NULL; + char *tmpPath = NULL; + bool freeTmpPath = false; + bool includeVFIO = false; +@@ -7317,11 +7316,7 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, + } + + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: +- if (!(mdev = virMediatedDeviceNew(mdevsrc->uuidstr, +- mdevsrc->model))) +- goto cleanup; +- +- if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdev))) ++ if (!(tmpPath = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr))) + goto cleanup; + + freeTmpPath = true; +@@ -7377,7 +7372,6 @@ qemuDomainGetHostdevPath(virDomainDefPtr def, + virUSBDeviceFree(usb); + virSCSIDeviceFree(scsi); + virSCSIVHostDeviceFree(host); +- virMediatedDeviceFree(mdev); + if (freeTmpPath) + VIR_FREE(tmpPath); + return ret; +diff --git a/src/security/security_apparmor.c b/src/security/security_apparmor.c +index fc5581526..62672b0af 100644 +--- a/src/security/security_apparmor.c ++++ b/src/security/security_apparmor.c +@@ -905,21 +905,13 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr, + + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: { + char *vfiodev = NULL; +- virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr, +- mdevsrc->model); + +- if (!mdev) ++ if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr))) + goto done; + +- if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) { +- virMediatedDeviceFree(mdev); +- goto done; +- } +- + ret = AppArmorSetSecurityHostdevLabelHelper(vfiodev, ptr); + + VIR_FREE(vfiodev); +- virMediatedDeviceFree(mdev); + break; + } + +diff --git a/src/security/security_dac.c b/src/security/security_dac.c +index 922e48494..7dcf4c15f 100644 +--- a/src/security/security_dac.c ++++ b/src/security/security_dac.c +@@ -968,21 +968,13 @@ virSecurityDACSetHostdevLabel(virSecurityManagerPtr mgr, + + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: { + char *vfiodev = NULL; +- virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr, +- mdevsrc->model); + +- if (!mdev) ++ if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr))) + goto done; + +- if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) { +- virMediatedDeviceFree(mdev); +- goto done; +- } +- + ret = virSecurityDACSetHostdevLabelHelper(vfiodev, &cbdata); + + VIR_FREE(vfiodev); +- virMediatedDeviceFree(mdev); + break; + } + +@@ -1144,21 +1136,13 @@ virSecurityDACRestoreHostdevLabel(virSecurityManagerPtr mgr, + + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: { + char *vfiodev = NULL; +- virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr, +- mdevsrc->model); + +- if (!mdev) ++ if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr))) + goto done; + +- if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) { +- virMediatedDeviceFree(mdev); +- goto done; +- } +- + ret = virSecurityDACRestoreFileLabel(virSecurityManagerGetPrivateData(mgr), + vfiodev); + VIR_FREE(vfiodev); +- virMediatedDeviceFree(mdev); + break; + } + +diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c +index df7c96833..c7a2dfe98 100644 +--- a/src/security/security_selinux.c ++++ b/src/security/security_selinux.c +@@ -1843,21 +1843,13 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManagerPtr mgr, + + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: { + char *vfiodev = NULL; +- virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr, +- mdevsrc->model); + +- if (!mdev) ++ if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr))) + goto done; + +- if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) { +- virMediatedDeviceFree(mdev); +- goto done; +- } +- + ret = virSecuritySELinuxSetHostdevLabelHelper(vfiodev, &data); + + VIR_FREE(vfiodev); +- virMediatedDeviceFree(mdev); + break; + } + +@@ -2092,21 +2084,13 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManagerPtr mgr, + + case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_MDEV: { + char *vfiodev = NULL; +- virMediatedDevicePtr mdev = virMediatedDeviceNew(mdevsrc->uuidstr, +- mdevsrc->model); + +- if (!mdev) ++ if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdevsrc->uuidstr))) + goto done; + +- if (!(vfiodev = virMediatedDeviceGetIOMMUGroupDev(mdev))) { +- virMediatedDeviceFree(mdev); +- goto done; +- } +- + ret = virSecuritySELinuxRestoreFileLabel(mgr, vfiodev); + + VIR_FREE(vfiodev); +- virMediatedDeviceFree(mdev); + break; + } + +diff --git a/src/util/virmdev.c b/src/util/virmdev.c +index c861d21c9..169deedfd 100644 +--- a/src/util/virmdev.c ++++ b/src/util/virmdev.c +@@ -209,43 +209,48 @@ virMediatedDeviceGetPath(virMediatedDevicePtr dev) + * for freeing the result. + */ + char * +-virMediatedDeviceGetIOMMUGroupDev(virMediatedDevicePtr dev) ++virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr) + { +- char *resultpath = NULL; ++ char *result_path = NULL; + char *iommu_path = NULL; + char *vfio_path = NULL; ++ char *dev_path = virMediatedDeviceGetSysfsPath(uuidstr); + +- if (virAsprintf(&iommu_path, "%s/iommu_group", dev->path) < 0) ++ if (!dev_path) + return NULL; + ++ if (virAsprintf(&iommu_path, "%s/iommu_group", dev_path) < 0) ++ goto cleanup; ++ + if (!virFileExists(iommu_path)) { + virReportSystemError(errno, _("failed to access '%s'"), iommu_path); + goto cleanup; + } + +- if (virFileResolveLink(iommu_path, &resultpath) < 0) { ++ if (virFileResolveLink(iommu_path, &result_path) < 0) { + virReportSystemError(errno, _("failed to resolve '%s'"), iommu_path); + goto cleanup; + } + +- if (virAsprintf(&vfio_path, "/dev/vfio/%s", last_component(resultpath)) < 0) ++ if (virAsprintf(&vfio_path, "/dev/vfio/%s", last_component(result_path)) < 0) + goto cleanup; + + cleanup: +- VIR_FREE(resultpath); ++ VIR_FREE(result_path); + VIR_FREE(iommu_path); ++ VIR_FREE(dev_path); + return vfio_path; + } + + + int +-virMediatedDeviceGetIOMMUGroupNum(virMediatedDevicePtr dev) ++virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr) + { + char *vfio_path = NULL; + char *group_num_str = NULL; + unsigned int group_num = -1; + +- if (!(vfio_path = virMediatedDeviceGetIOMMUGroupDev(dev))) ++ if (!(vfio_path = virMediatedDeviceGetIOMMUGroupDev(uuidstr))) + return -1; + + group_num_str = last_component(vfio_path); +diff --git a/src/util/virmdev.h b/src/util/virmdev.h +index 8bb46b9c5..0b8e830f4 100644 +--- a/src/util/virmdev.h ++++ b/src/util/virmdev.h +@@ -65,10 +65,10 @@ virMediatedDeviceSetUsedBy(virMediatedDevicePtr dev, + const char *domname); + + char * +-virMediatedDeviceGetIOMMUGroupDev(virMediatedDevicePtr dev); ++virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr); + + int +-virMediatedDeviceGetIOMMUGroupNum(virMediatedDevicePtr dev); ++virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr); + + char * + virMediatedDeviceGetSysfsPath(const char *uuidstr); +-- +2.13.0 + diff --git a/SOURCES/libvirt-network-better-log-message-when-network-is-inactive-during-reconnect.patch b/SOURCES/libvirt-network-better-log-message-when-network-is-inactive-during-reconnect.patch new file mode 100644 index 0000000..6689d63 --- /dev/null +++ b/SOURCES/libvirt-network-better-log-message-when-network-is-inactive-during-reconnect.patch @@ -0,0 +1,42 @@ +From c85276bfbfda6818ae1dddbe91d971cb26669044 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Laine Stump +Date: Tue, 2 May 2017 12:31:52 -0400 +Subject: [PATCH] network: better log message when network is inactive during + reconnect + +If the network isn't active during networkNotifyActualDevice(), we +would log an error message stating that the bridge device didn't +exist. This patch adds a check to see if the network is active, making +the logs more useful in the case that it isn't. + +Partially resolves: https://bugzilla.redhat.com/1442700 + +(cherry picked from commit 7949de960eaba07661c1e0ab6e4aa945db8c1b25) + +Signed-off-by: Jiri Denemark +--- + src/network/bridge_driver.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c +index cb91a2c90..41bce794a 100644 +--- a/src/network/bridge_driver.c ++++ b/src/network/bridge_driver.c +@@ -4682,6 +4682,13 @@ networkNotifyActualDevice(virDomainDefPtr dom, + } + netdef = network->def; + ++ if (!virNetworkObjIsActive(network)) { ++ virReportError(VIR_ERR_OPERATION_INVALID, ++ _("network '%s' is not active"), ++ netdef->name); ++ goto error; ++ } ++ + /* if we're restarting libvirtd after an upgrade from a version + * that didn't save bridge name in actualNetDef for + * actualType==network, we need to copy it in so that it will be +-- +2.12.2 + diff --git a/SOURCES/libvirt-network-new-network-forward-mode-open.patch b/SOURCES/libvirt-network-new-network-forward-mode-open.patch deleted file mode 100644 index fba4a3f..0000000 --- a/SOURCES/libvirt-network-new-network-forward-mode-open.patch +++ /dev/null @@ -1,416 +0,0 @@ -From b238953664fffd85c3dc35554ba7ab62638aeb5e Mon Sep 17 00:00:00 2001 -Message-Id: -From: Laine Stump -Date: Sat, 27 Aug 2016 12:28:08 -0400 -Subject: [PATCH] network: new network forward mode 'open' - -The new forward mode 'open' is just like mode='route', except that no -firewall rules are added to assure that any traffic does or doesn't -pass. It is assumed that either they aren't necessary, or they will be -setup outside the scope of libvirt. - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=846810 - -(cherry picked from commit 25e8112d7c32ab271b9cae28f3ccbf5835206693) ---- - docs/formatnetwork.html.in | 22 ++++++++++++ - docs/schemas/network.rng | 1 + - src/conf/network_conf.c | 25 +++++++++++-- - src/conf/network_conf.h | 1 + - src/network/bridge_driver.c | 41 +++++++++++++++------- - tests/networkxml2confdata/open-network.conf | 11 ++++++ - tests/networkxml2confdata/open-network.xml | 9 +++++ - tests/networkxml2conftest.c | 1 + - .../open-network-with-forward-dev.xml | 9 +++++ - tests/networkxml2xmlin/open-network.xml | 9 +++++ - tests/networkxml2xmlout/open-network.xml | 9 +++++ - tests/networkxml2xmltest.c | 2 ++ - 12 files changed, 125 insertions(+), 15 deletions(-) - create mode 100644 tests/networkxml2confdata/open-network.conf - create mode 100644 tests/networkxml2confdata/open-network.xml - create mode 100644 tests/networkxml2xmlin/open-network-with-forward-dev.xml - create mode 100644 tests/networkxml2xmlin/open-network.xml - create mode 100644 tests/networkxml2xmlout/open-network.xml - -diff --git a/docs/formatnetwork.html.in b/docs/formatnetwork.html.in -index 1cea931..619b10e 100644 ---- a/docs/formatnetwork.html.in -+++ b/docs/formatnetwork.html.in -@@ -250,6 +250,28 @@ - Since 0.4.2 - - -+
      open
      -+
      -+ As with mode='route', guest network traffic will be -+ forwarded to the physical network via the host's IP -+ routing stack, but there will be no firewall rules added -+ to either enable or prevent any of this traffic. When -+ forward='open' is set, the dev attribute -+ cannot be set (because the forward dev is enforced with -+ firewall rules, and the purpose of forward='open' is to -+ have a forwarding mode where libvirt doesn't add any -+ firewall rules). This mode presumes that the local LAN -+ router has suitable routing table entries to return -+ traffic to this host, and that some other management -+ system has been used to put in place any necessary -+ firewall rules. Although no firewall rules will be added -+ for the network, it is of course still possible to add -+ restrictions for specific guests using -+ nwfilter rules on the -+ guests' interfaces.) -+ Since 2.2.0 -+
      -+ -
      bridge
      -
      - This network describes either 1) an existing host bridge -diff --git a/docs/schemas/network.rng b/docs/schemas/network.rng -index 4edb6eb..8a1be68 100644 ---- a/docs/schemas/network.rng -+++ b/docs/schemas/network.rng -@@ -101,6 +101,7 @@ - - nat - route -+ open - bridge - passthrough - private -diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c -index 2d904df..1990cfc 100644 ---- a/src/conf/network_conf.c -+++ b/src/conf/network_conf.c -@@ -57,7 +57,9 @@ struct _virNetworkObjList { - - VIR_ENUM_IMPL(virNetworkForward, - VIR_NETWORK_FORWARD_LAST, -- "none", "nat", "route", "bridge", "private", "vepa", "passthrough", "hostdev") -+ "none", "nat", "route", "open", -+ "bridge", "private", "vepa", "passthrough", -+ "hostdev") - - VIR_ENUM_IMPL(virNetworkBridgeMACTableManager, - VIR_NETWORK_BRIDGE_MAC_TABLE_MANAGER_LAST, -@@ -2329,6 +2331,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) - - case VIR_NETWORK_FORWARD_ROUTE: - case VIR_NETWORK_FORWARD_NAT: -+ case VIR_NETWORK_FORWARD_OPEN: - /* It's pointless to specify L3 forwarding without specifying - * the network we're on. - */ -@@ -2347,6 +2350,19 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) - def->name); - goto error; - } -+ -+ if (def->forward.type == VIR_NETWORK_FORWARD_OPEN && def->forward.nifs) { -+ /* an open network by definition can't place any restrictions -+ * on what traffic is allowed or where it goes, so specifying -+ * a forwarding device is nonsensical. -+ */ -+ virReportError(VIR_ERR_XML_ERROR, -+ _("forward dev not allowed for " -+ "network '%s' with forward mode='%s'"), -+ def->name, -+ virNetworkForwardTypeToString(def->forward.type)); -+ goto error; -+ } - break; - - case VIR_NETWORK_FORWARD_PRIVATE: -@@ -2820,13 +2836,15 @@ virNetworkDefFormatBuf(virBufferPtr buf, - if (def->forward.type == VIR_NETWORK_FORWARD_NONE || - def->forward.type == VIR_NETWORK_FORWARD_NAT || - def->forward.type == VIR_NETWORK_FORWARD_ROUTE || -+ def->forward.type == VIR_NETWORK_FORWARD_OPEN || - def->bridge || def->macTableManager) { - - virBufferAddLit(buf, "bridge); - if (def->forward.type == VIR_NETWORK_FORWARD_NONE || - def->forward.type == VIR_NETWORK_FORWARD_NAT || -- def->forward.type == VIR_NETWORK_FORWARD_ROUTE) { -+ def->forward.type == VIR_NETWORK_FORWARD_ROUTE || -+ def->forward.type == VIR_NETWORK_FORWARD_OPEN) { - virBufferAsprintf(buf, " stp='%s' delay='%ld'", - def->stp ? "on" : "off", def->delay); - } -@@ -3199,7 +3217,8 @@ virNetworkObjPtr virNetworkLoadConfig(virNetworkObjListPtr nets, - - if (def->forward.type == VIR_NETWORK_FORWARD_NONE || - def->forward.type == VIR_NETWORK_FORWARD_NAT || -- def->forward.type == VIR_NETWORK_FORWARD_ROUTE) { -+ def->forward.type == VIR_NETWORK_FORWARD_ROUTE || -+ def->forward.type == VIR_NETWORK_FORWARD_OPEN) { - - if (!def->mac_specified) { - virNetworkSetBridgeMacAddr(def); -diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h -index e7ce674..bba99e2 100644 ---- a/src/conf/network_conf.h -+++ b/src/conf/network_conf.h -@@ -46,6 +46,7 @@ typedef enum { - VIR_NETWORK_FORWARD_NONE = 0, - VIR_NETWORK_FORWARD_NAT, - VIR_NETWORK_FORWARD_ROUTE, -+ VIR_NETWORK_FORWARD_OPEN, - VIR_NETWORK_FORWARD_BRIDGE, - VIR_NETWORK_FORWARD_PRIVATE, - VIR_NETWORK_FORWARD_VEPA, -diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c -index 0221a38..c6ab6a1 100644 ---- a/src/network/bridge_driver.c -+++ b/src/network/bridge_driver.c -@@ -400,6 +400,7 @@ networkUpdateState(virNetworkObjPtr obj, - case VIR_NETWORK_FORWARD_NONE: - case VIR_NETWORK_FORWARD_NAT: - case VIR_NETWORK_FORWARD_ROUTE: -+ case VIR_NETWORK_FORWARD_OPEN: - /* If bridge doesn't exist, then mark it inactive */ - if (!(obj->def->bridge && virNetDevExists(obj->def->bridge) == 1)) - obj->active = 0; -@@ -1815,7 +1816,8 @@ networkRefreshDaemonsHelper(virNetworkObjPtr net, - if (virNetworkObjIsActive(net) && - ((net->def->forward.type == VIR_NETWORK_FORWARD_NONE) || - (net->def->forward.type == VIR_NETWORK_FORWARD_NAT) || -- (net->def->forward.type == VIR_NETWORK_FORWARD_ROUTE))) { -+ (net->def->forward.type == VIR_NETWORK_FORWARD_ROUTE) || -+ (net->def->forward.type == VIR_NETWORK_FORWARD_OPEN))) { - /* Only the three L3 network types that are configured by - * libvirt will have a dnsmasq or radvd daemon associated - * with them. Here we send a SIGHUP to an existing -@@ -1851,8 +1853,10 @@ networkReloadFirewallRulesHelper(virNetworkObjPtr net, - ((net->def->forward.type == VIR_NETWORK_FORWARD_NONE) || - (net->def->forward.type == VIR_NETWORK_FORWARD_NAT) || - (net->def->forward.type == VIR_NETWORK_FORWARD_ROUTE))) { -- /* Only the three L3 network types that are configured by libvirt -- * need to have iptables rules reloaded. -+ /* Only three of the L3 network types that are configured by -+ * libvirt need to have iptables rules reloaded. The 4th L3 -+ * network type, forward='open', doesn't need this because it -+ * has no iptables rules. - */ - networkRemoveFirewallRules(net->def); - if (networkAddFirewallRules(net->def) < 0) { -@@ -2135,7 +2139,8 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, - goto err1; - - /* Add "once per network" rules */ -- if (networkAddFirewallRules(network->def) < 0) -+ if (network->def->forward.type != VIR_NETWORK_FORWARD_OPEN && -+ networkAddFirewallRules(network->def) < 0) - goto err1; - - for (i = 0; -@@ -2237,7 +2242,8 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, - err2: - if (!save_err) - save_err = virSaveLastError(); -- networkRemoveFirewallRules(network->def); -+ if (network->def->forward.type != VIR_NETWORK_FORWARD_OPEN) -+ networkRemoveFirewallRules(network->def); - - err1: - if (!save_err) -@@ -2293,7 +2299,8 @@ networkShutdownNetworkVirtual(virNetworkDriverStatePtr driver, - - ignore_value(virNetDevSetOnline(network->def->bridge, 0)); - -- networkRemoveFirewallRules(network->def); -+ if (network->def->forward.type != VIR_NETWORK_FORWARD_OPEN) -+ networkRemoveFirewallRules(network->def); - - ignore_value(virNetDevBridgeDelete(network->def->bridge)); - -@@ -2400,6 +2407,7 @@ networkCreateInterfacePool(virNetworkDefPtr netdef) - case VIR_NETWORK_FORWARD_NONE: - case VIR_NETWORK_FORWARD_NAT: - case VIR_NETWORK_FORWARD_ROUTE: -+ case VIR_NETWORK_FORWARD_OPEN: - case VIR_NETWORK_FORWARD_LAST: - /* by definition these will never be encountered here */ - break; -@@ -2493,6 +2501,7 @@ networkStartNetwork(virNetworkDriverStatePtr driver, - case VIR_NETWORK_FORWARD_NONE: - case VIR_NETWORK_FORWARD_NAT: - case VIR_NETWORK_FORWARD_ROUTE: -+ case VIR_NETWORK_FORWARD_OPEN: - if (networkStartNetworkVirtual(driver, network) < 0) - goto cleanup; - break; -@@ -2571,6 +2580,7 @@ networkShutdownNetwork(virNetworkDriverStatePtr driver, - case VIR_NETWORK_FORWARD_NONE: - case VIR_NETWORK_FORWARD_NAT: - case VIR_NETWORK_FORWARD_ROUTE: -+ case VIR_NETWORK_FORWARD_OPEN: - ret = networkShutdownNetworkVirtual(driver, network); - break; - -@@ -2919,7 +2929,8 @@ networkValidate(virNetworkDriverStatePtr driver, - */ - if (def->forward.type == VIR_NETWORK_FORWARD_NONE || - def->forward.type == VIR_NETWORK_FORWARD_NAT || -- def->forward.type == VIR_NETWORK_FORWARD_ROUTE) { -+ def->forward.type == VIR_NETWORK_FORWARD_ROUTE || -+ def->forward.type == VIR_NETWORK_FORWARD_OPEN) { - - /* if no bridge name was given in the config, find a name - * unused by any other libvirt networks and assign it. -@@ -3360,8 +3371,10 @@ networkUpdate(virNetworkPtr net, - * old rules (and remember to load new ones after the - * update). - */ -- networkRemoveFirewallRules(network->def); -- needFirewallRefresh = true; -+ if (network->def->forward.type != VIR_NETWORK_FORWARD_OPEN) { -+ networkRemoveFirewallRules(network->def); -+ needFirewallRefresh = true; -+ } - break; - default: - break; -@@ -4037,7 +4050,8 @@ networkAllocateActualDevice(virDomainDefPtr dom, - - if ((netdef->forward.type == VIR_NETWORK_FORWARD_NONE) || - (netdef->forward.type == VIR_NETWORK_FORWARD_NAT) || -- (netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE)) { -+ (netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE) || -+ (netdef->forward.type == VIR_NETWORK_FORWARD_OPEN)) { - /* for these forward types, the actual net type really *is* - * NETWORK; we just keep the info from the portgroup in - * iface->data.network.actual -@@ -4581,7 +4595,8 @@ networkReleaseActualDevice(virDomainDefPtr dom, - if (iface->data.network.actual && - (netdef->forward.type == VIR_NETWORK_FORWARD_NONE || - netdef->forward.type == VIR_NETWORK_FORWARD_NAT || -- netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE) && -+ netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE || -+ netdef->forward.type == VIR_NETWORK_FORWARD_OPEN) && - networkUnplugBandwidth(network, iface) < 0) - goto error; - -@@ -4728,6 +4743,7 @@ networkGetNetworkAddress(const char *netname, char **netaddr) - case VIR_NETWORK_FORWARD_NONE: - case VIR_NETWORK_FORWARD_NAT: - case VIR_NETWORK_FORWARD_ROUTE: -+ case VIR_NETWORK_FORWARD_OPEN: - ipdef = virNetworkDefGetIPByIndex(netdef, AF_UNSPEC, 0); - if (!ipdef) { - virReportError(VIR_ERR_INTERNAL_ERROR, -@@ -4811,7 +4827,8 @@ networkGetActualType(virDomainNetDefPtr iface) - - if ((netdef->forward.type == VIR_NETWORK_FORWARD_NONE) || - (netdef->forward.type == VIR_NETWORK_FORWARD_NAT) || -- (netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE)) { -+ (netdef->forward.type == VIR_NETWORK_FORWARD_ROUTE) || -+ (netdef->forward.type == VIR_NETWORK_FORWARD_OPEN)) { - /* for these forward types, the actual net type really *is* - * NETWORK; we just keep the info from the portgroup in - * iface->data.network.actual -diff --git a/tests/networkxml2confdata/open-network.conf b/tests/networkxml2confdata/open-network.conf -new file mode 100644 -index 0000000..ff09984 ---- /dev/null -+++ b/tests/networkxml2confdata/open-network.conf -@@ -0,0 +1,11 @@ -+##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE -+##OVERWRITTEN AND LOST. Changes to this configuration should be made using: -+## virsh net-edit open -+## or other application using the libvirt API. -+## -+## dnsmasq conf file created by libvirt -+strict-order -+except-interface=lo -+bind-dynamic -+interface=virbr1 -+addn-hosts=/var/lib/libvirt/dnsmasq/open.addnhosts -diff --git a/tests/networkxml2confdata/open-network.xml b/tests/networkxml2confdata/open-network.xml -new file mode 100644 -index 0000000..e0b3f03 ---- /dev/null -+++ b/tests/networkxml2confdata/open-network.xml -@@ -0,0 +1,9 @@ -+ -+ open -+ 81ff0d90-c91e-6742-64da-4a736edb9a9b -+ -+ -+ -+ -+ -+ -diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c -index 11e08c0..77acc53 100644 ---- a/tests/networkxml2conftest.c -+++ b/tests/networkxml2conftest.c -@@ -117,6 +117,7 @@ mymain(void) - DO_TEST("nat-network-dns-srv-record-minimal", restricted); - DO_TEST("nat-network-name-with-quotes", restricted); - DO_TEST("routed-network", full); -+ DO_TEST("open-network", full); - DO_TEST("nat-network", dhcpv6); - DO_TEST("nat-network-dns-txt-record", full); - DO_TEST("nat-network-dns-srv-record", full); -diff --git a/tests/networkxml2xmlin/open-network-with-forward-dev.xml b/tests/networkxml2xmlin/open-network-with-forward-dev.xml -new file mode 100644 -index 0000000..33e8bb5 ---- /dev/null -+++ b/tests/networkxml2xmlin/open-network-with-forward-dev.xml -@@ -0,0 +1,9 @@ -+ -+ open -+ 81ff0d90-c91e-6742-64da-4a736edb9a9b -+ -+ -+ -+ -+ -+ -diff --git a/tests/networkxml2xmlin/open-network.xml b/tests/networkxml2xmlin/open-network.xml -new file mode 100644 -index 0000000..2e4b9b2 ---- /dev/null -+++ b/tests/networkxml2xmlin/open-network.xml -@@ -0,0 +1,9 @@ -+ -+ open -+ 81ff0d90-c91e-6742-64da-4a736edb9a9b -+ -+ -+ -+ -+ -+ -diff --git a/tests/networkxml2xmlout/open-network.xml b/tests/networkxml2xmlout/open-network.xml -new file mode 100644 -index 0000000..29e9684 ---- /dev/null -+++ b/tests/networkxml2xmlout/open-network.xml -@@ -0,0 +1,9 @@ -+ -+ open -+ 81ff0d90-c91e-6742-64da-4a736edb9a9b -+ -+ -+ -+ -+ -+ -diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c -index d65f6aa..9114c1e 100644 ---- a/tests/networkxml2xmltest.c -+++ b/tests/networkxml2xmltest.c -@@ -127,6 +127,8 @@ mymain(void) - DO_TEST("empty-allow-ipv6"); - DO_TEST("isolated-network"); - DO_TEST("routed-network"); -+ DO_TEST("open-network"); -+ DO_TEST_PARSE_ERROR("open-network-with-forward-dev"); - DO_TEST("nat-network"); - DO_TEST("netboot-network"); - DO_TEST("netboot-proxy-network"); --- -2.10.0 - diff --git a/SOURCES/libvirt-nodedev-Increase-the-netlink-socket-buffer-size-to-the-one-used-by-udev.patch b/SOURCES/libvirt-nodedev-Increase-the-netlink-socket-buffer-size-to-the-one-used-by-udev.patch new file mode 100644 index 0000000..526a99f --- /dev/null +++ b/SOURCES/libvirt-nodedev-Increase-the-netlink-socket-buffer-size-to-the-one-used-by-udev.patch @@ -0,0 +1,53 @@ +From c0b489c317a0cd3b709008d742d6653634455ded Mon Sep 17 00:00:00 2001 +Message-Id: +From: "ning.bo" +Date: Mon, 29 May 2017 16:22:50 +0200 +Subject: [PATCH] nodedev: Increase the netlink socket buffer size to the one + used by udev + +When a number of SRIOV VFs (up to 128 on Intel XL710) is created: +for i in `seq 0 1`; do + echo 63 > /sys/class/net//device/sriov_numvfs +done + +libvirtd will then report "udev_monitor_receive_device returned NULL" +error because the netlink socket buffer is not big enough (using GDB on +libudev confirmed this with ENOBUFFS) and thus some udev events were +dropped. This results in some devices being missing in the nodedev-list +output. This patch overrides the system's rmem_max limit but for that, +we need to make sure we've got root privileges. + +https://bugzilla.redhat.com/show_bug.cgi?id=1450960 + +Signed-off-by: ning.bo +Signed-off-by: Erik Skultety +(cherry picked from commit d1eea6c12aad5cb503562a52915138bf0d0a70a2) + +https://bugzilla.redhat.com/show_bug.cgi?id=1442307 +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + src/node_device/node_device_udev.c | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index 37528ee48..20c0fc837 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -1732,6 +1732,13 @@ static int nodeStateInitialize(bool privileged, + + udev_monitor_enable_receiving(priv->udev_monitor); + ++ /* mimic udevd's behaviour and override the systems rmem_max limit in case ++ * there's a significant number of device 'add' events ++ */ ++ if (geteuid() == 0) ++ udev_monitor_set_receive_buffer_size(priv->udev_monitor, ++ 128 * 1024 * 1024); ++ + /* We register the monitor with the event callback so we are + * notified by udev of device changes before we enumerate existing + * devices because libvirt will simply recreate the device if we +-- +2.13.0 + diff --git a/SOURCES/libvirt-nodedev-Introduce-mdev-capability-for-mediated-devices.patch b/SOURCES/libvirt-nodedev-Introduce-mdev-capability-for-mediated-devices.patch new file mode 100644 index 0000000..9db594c --- /dev/null +++ b/SOURCES/libvirt-nodedev-Introduce-mdev-capability-for-mediated-devices.patch @@ -0,0 +1,282 @@ +From 8e5ac9cdbe38dd3b3320b97385d8e2cf0e862ef7 Mon Sep 17 00:00:00 2001 +Message-Id: <8e5ac9cdbe38dd3b3320b97385d8e2cf0e862ef7@dist-git> +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:54 +0200 +Subject: [PATCH] nodedev: Introduce mdev capability for mediated devices + +Start discovering the mediated devices on the host system and format the +attributes for the mediated device into the XML. Compared to the parent +device which reports generic information about the abstract mediated +devices types, a child device only reports the type name it has been +instantiated from and the IOMMU group number, since that's device +specific compared to the rest of the info that can be gathered about +mediated devices at the moment. +This patch introduces both the formatting and parsing routines, updates +nodedev.rng schema, adding a testcase as well. + +The resulting mdev child device XML: + + mdev_4b20d080_1b54_4048_85b3_a6a62d165c01 + /sys/devices/.../4b20d080-1b54-4048-85b3-a6a62d165c01 + pci_0000_06_00_0 + + vfio_mdev + + + + + + + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit 88ef73e13cddc8c0ff01dfe7a914342f8720c517) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + docs/schemas/nodedev.rng | 17 +++++++++ + src/conf/node_device_conf.c | 41 +++++++++++++++++++++ + src/conf/node_device_conf.h | 8 ++++ + src/node_device/node_device_udev.c | 43 +++++++++++++++++++++- + .../mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml | 8 ++++ + tests/nodedevxml2xmltest.c | 1 + + 6 files changed, 117 insertions(+), 1 deletion(-) + create mode 100644 tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml + +diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng +index e0a2c5032..924f73861 100644 +--- a/docs/schemas/nodedev.rng ++++ b/docs/schemas/nodedev.rng +@@ -83,6 +83,7 @@ + + + ++ + + + +@@ -580,6 +581,22 @@ + + + ++ ++ ++ mdev ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index de8ba8f9d..ac61db34c 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -577,6 +577,10 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) + virBufferEscapeString(&buf, "%s\n", virNodeDevDRMTypeToString(data->drm.type)); + break; + case VIR_NODE_DEV_CAP_MDEV: ++ virBufferEscapeString(&buf, "\n", data->mdev.type); ++ virBufferAsprintf(&buf, "\n", ++ data->mdev.iommuGroupNumber); ++ break; + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: +@@ -1647,6 +1651,39 @@ virNodeDevCapSystemParseXML(xmlXPathContextPtr ctxt, + } + + ++static int ++virNodeDevCapMdevParseXML(xmlXPathContextPtr ctxt, ++ virNodeDeviceDefPtr def, ++ xmlNodePtr node, ++ virNodeDevCapMdevPtr mdev) ++{ ++ xmlNodePtr orignode; ++ int ret = -1; ++ ++ orignode = ctxt->node; ++ ctxt->node = node; ++ ++ if (!(mdev->type = virXPathString("string(./type[1]/@id)", ctxt))) { ++ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, ++ _("missing type id attribute for '%s'"), def->name); ++ goto out; ++ } ++ ++ if (virNodeDevCapsDefParseULong("number(./iommuGroup[1]/@number)", ctxt, ++ &mdev->iommuGroupNumber, def, ++ _("missing iommuGroup number attribute for " ++ "'%s'"), ++ _("invalid iommuGroup number attribute for " ++ "'%s'")) < 0) ++ goto out; ++ ++ ret = 0; ++ out: ++ ctxt->node = orignode; ++ return ret; ++} ++ ++ + static virNodeDevCapsDefPtr + virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, + virNodeDeviceDefPtr def, +@@ -1715,6 +1752,8 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, + ret = virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data.drm); + break; + case VIR_NODE_DEV_CAP_MDEV: ++ ret = virNodeDevCapMdevParseXML(ctxt, def, node, &caps->data.mdev); ++ break; + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: +@@ -2037,6 +2076,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) + VIR_FREE(data->sg.path); + break; + case VIR_NODE_DEV_CAP_MDEV: ++ VIR_FREE(data->mdev.type); ++ break; + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_DRM: + case VIR_NODE_DEV_CAP_FC_HOST: +diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h +index 18aaff8b5..5743f9d3e 100644 +--- a/src/conf/node_device_conf.h ++++ b/src/conf/node_device_conf.h +@@ -143,6 +143,13 @@ struct _virNodeDevCapMdevType { + unsigned int available_instances; + }; + ++typedef struct _virNodeDevCapMdev virNodeDevCapMdev; ++typedef virNodeDevCapMdev *virNodeDevCapMdevPtr; ++struct _virNodeDevCapMdev { ++ char *type; ++ unsigned int iommuGroupNumber; ++}; ++ + typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev; + typedef virNodeDevCapPCIDev *virNodeDevCapPCIDevPtr; + struct _virNodeDevCapPCIDev { +@@ -276,6 +283,7 @@ struct _virNodeDevCapData { + virNodeDevCapStorage storage; + virNodeDevCapSCSIGeneric sg; + virNodeDevCapDRM drm; ++ virNodeDevCapMdev mdev; + }; + }; + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index b89099c82..37528ee48 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -1073,6 +1073,42 @@ udevProcessSCSIGeneric(struct udev_device *dev, + } + + static int ++udevProcessMediatedDevice(struct udev_device *dev, ++ virNodeDeviceDefPtr def) ++{ ++ int ret = -1; ++ const char *uuidstr = NULL; ++ int iommugrp = -1; ++ char *linkpath = NULL; ++ char *realpath = NULL; ++ virNodeDevCapMdevPtr data = &def->caps->data.mdev; ++ ++ if (virAsprintf(&linkpath, "%s/mdev_type", udev_device_get_syspath(dev)) < 0) ++ goto cleanup; ++ ++ if (virFileResolveLink(linkpath, &realpath) < 0) ++ goto cleanup; ++ ++ if (VIR_STRDUP(data->type, last_component(realpath)) < 0) ++ goto cleanup; ++ ++ uuidstr = udev_device_get_sysname(dev); ++ if ((iommugrp = virMediatedDeviceGetIOMMUGroupNum(uuidstr)) < 0) ++ goto cleanup; ++ ++ if (udevGenerateDeviceName(dev, def, NULL) != 0) ++ goto cleanup; ++ ++ data->iommuGroupNumber = iommugrp; ++ ++ ret = 0; ++ cleanup: ++ VIR_FREE(linkpath); ++ VIR_FREE(realpath); ++ return ret; ++} ++ ++static int + udevGetDeviceNodes(struct udev_device *device, + virNodeDeviceDefPtr def) + { +@@ -1140,12 +1176,16 @@ udevGetDeviceType(struct udev_device *device, + if (udevHasDeviceProperty(device, "INTERFACE")) + *type = VIR_NODE_DEV_CAP_NET; + +- /* SCSI generic device doesn't set DEVTYPE property */ ++ /* Neither SCSI generic devices nor mediated devices set DEVTYPE ++ * property, therefore we need to rely on the SUBSYSTEM property */ + if (udevGetStringProperty(device, "SUBSYSTEM", &subsystem) < 0) + return -1; + + if (STREQ_NULLABLE(subsystem, "scsi_generic")) + *type = VIR_NODE_DEV_CAP_SCSI_GENERIC; ++ else if (STREQ_NULLABLE(subsystem, "mdev")) ++ *type = VIR_NODE_DEV_CAP_MDEV; ++ + VIR_FREE(subsystem); + } + +@@ -1185,6 +1225,7 @@ static int udevGetDeviceDetails(struct udev_device *device, + case VIR_NODE_DEV_CAP_DRM: + return udevProcessDRMDevice(device, def); + case VIR_NODE_DEV_CAP_MDEV: ++ return udevProcessMediatedDevice(device, def); + case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_SYSTEM: + case VIR_NODE_DEV_CAP_FC_HOST: +diff --git a/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml b/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml +new file mode 100644 +index 000000000..470e5917e +--- /dev/null ++++ b/tests/nodedevschemadata/mdev_3627463d_b7f0_4fea_b468_f1da537d301b.xml +@@ -0,0 +1,8 @@ ++ ++ mdev_3627463d_b7f0_4fea_b468_f1da537d301b ++ computer ++ ++ ++ ++ ++ +diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c +index eb5c50b86..26f0d25bc 100644 +--- a/tests/nodedevxml2xmltest.c ++++ b/tests/nodedevxml2xmltest.c +@@ -102,6 +102,7 @@ mymain(void) + DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type"); + DO_TEST("drm_renderD129"); + DO_TEST("pci_0000_02_10_7_mdev_types"); ++ DO_TEST("mdev_3627463d_b7f0_4fea_b468_f1da537d301b"); + + return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; + } +-- +2.13.0 + diff --git a/SOURCES/libvirt-nodedev-Introduce-new-mdev_types-and-mdev-nodedev-capabilities.patch b/SOURCES/libvirt-nodedev-Introduce-new-mdev_types-and-mdev-nodedev-capabilities.patch new file mode 100644 index 0000000..11333ed --- /dev/null +++ b/SOURCES/libvirt-nodedev-Introduce-new-mdev_types-and-mdev-nodedev-capabilities.patch @@ -0,0 +1,193 @@ +From 74e4d42a25e8e8823ce4e7c3544b8f1944cdb471 Mon Sep 17 00:00:00 2001 +Message-Id: <74e4d42a25e8e8823ce4e7c3544b8f1944cdb471@dist-git> +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:52 +0200 +Subject: [PATCH] nodedev: Introduce new mdev_types and mdev nodedev + capabilities + +The reason for introducing two capabilities, one for the device itself +(cap 'mdev') and one for the parent device listing the available types +('mdev_types'), is that we should be able to do +'virsh nodedev-list --cap' not only for existing mdev devices but also +for devices that support creation of mdev devices, since one day libvirt +might be actually able to create the mdev devices in an automated way +(just like we do for NPIV/vHBA). + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit 4385df97fed24279fa8595a1a49c9f9b3eba5be1) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + include/libvirt/libvirt-nodedev.h | 2 ++ + src/conf/node_device_conf.c | 10 +++++++++- + src/conf/node_device_conf.h | 6 +++++- + src/conf/virnodedeviceobj.c | 4 +++- + src/libvirt-nodedev.c | 2 ++ + src/node_device/node_device_driver.c | 2 ++ + src/node_device/node_device_udev.c | 3 +++ + tools/virsh-nodedev.c | 6 ++++++ + 8 files changed, 32 insertions(+), 3 deletions(-) + +diff --git a/include/libvirt/libvirt-nodedev.h b/include/libvirt/libvirt-nodedev.h +index 85003903d..1e3043787 100644 +--- a/include/libvirt/libvirt-nodedev.h ++++ b/include/libvirt/libvirt-nodedev.h +@@ -79,6 +79,8 @@ typedef enum { + VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS = 1 << 10, /* Capable of vport */ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC = 1 << 11, /* Capable of scsi_generic */ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM = 1 << 12, /* DRM device */ ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES = 1 << 13, /* Capable of mediated devices */ ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV = 1 << 14, /* Mediated device */ + } virConnectListAllNodeDeviceFlags; + + int virConnectListAllNodeDevices (virConnectPtr conn, +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 56a26b578..90a087a37 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -60,7 +60,9 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST, + "fc_host", + "vports", + "scsi_generic", +- "drm") ++ "drm", ++ "mdev_types", ++ "mdev") + + VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST, + "80203", +@@ -540,6 +542,8 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) + case VIR_NODE_DEV_CAP_DRM: + virBufferEscapeString(&buf, "%s\n", virNodeDevDRMTypeToString(data->drm.type)); + break; ++ case VIR_NODE_DEV_CAP_MDEV: ++ case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_LAST: +@@ -1612,6 +1616,8 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, + case VIR_NODE_DEV_CAP_DRM: + ret = virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data.drm); + break; ++ case VIR_NODE_DEV_CAP_MDEV: ++ case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_SCSI_GENERIC: +@@ -1929,6 +1935,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) + case VIR_NODE_DEV_CAP_SCSI_GENERIC: + VIR_FREE(data->sg.path); + break; ++ case VIR_NODE_DEV_CAP_MDEV: ++ case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_DRM: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: +diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h +index a5d5cdd2a..e168f2e27 100644 +--- a/src/conf/node_device_conf.h ++++ b/src/conf/node_device_conf.h +@@ -64,6 +64,8 @@ typedef enum { + VIR_NODE_DEV_CAP_VPORTS, /* HBA which is capable of vports */ + VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */ + VIR_NODE_DEV_CAP_DRM, /* DRM device */ ++ VIR_NODE_DEV_CAP_MDEV_TYPES, /* Device capable of mediated devices */ ++ VIR_NODE_DEV_CAP_MDEV, /* Mediated device */ + + VIR_NODE_DEV_CAP_LAST + } virNodeDevCapType; +@@ -351,7 +353,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps); + VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST | \ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS | \ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC | \ +- VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM) ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM | \ ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES | \ ++ VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV) + + char * + virNodeDeviceGetParentName(virConnectPtr conn, +diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c +index 3fe3ae5fe..21d5d3f75 100644 +--- a/src/conf/virnodedeviceobj.c ++++ b/src/conf/virnodedeviceobj.c +@@ -494,7 +494,9 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj, + MATCH(FC_HOST) || + MATCH(VPORTS) || + MATCH(SCSI_GENERIC) || +- MATCH(DRM))) ++ MATCH(DRM) || ++ MATCH(MDEV_TYPES) || ++ MATCH(MDEV))) + return false; + } + +diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c +index 83376b0d9..44e2b4efd 100644 +--- a/src/libvirt-nodedev.c ++++ b/src/libvirt-nodedev.c +@@ -98,6 +98,8 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags) + * VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS + * VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC + * VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM ++ * VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES ++ * VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV + * + * Returns the number of node devices found or -1 and sets @devices to NULL in + * case of error. On success, the array stored into @devices is guaranteed to +diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c +index 99f7bc547..082160d98 100644 +--- a/src/node_device/node_device_driver.c ++++ b/src/node_device/node_device_driver.c +@@ -82,6 +82,8 @@ static int update_caps(virNodeDeviceObjPtr dev) + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: + case VIR_NODE_DEV_CAP_SCSI_GENERIC: ++ case VIR_NODE_DEV_CAP_MDEV_TYPES: ++ case VIR_NODE_DEV_CAP_MDEV: + case VIR_NODE_DEV_CAP_LAST: + break; + } +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index 591da8db2..d4489e2a5 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -43,6 +43,7 @@ + #include "virpci.h" + #include "virstring.h" + #include "virnetdev.h" ++#include "virmdev.h" + + #define VIR_FROM_THIS VIR_FROM_NODEDEV + +@@ -1064,6 +1065,8 @@ static int udevGetDeviceDetails(struct udev_device *device, + return udevProcessSCSIGeneric(device, def); + case VIR_NODE_DEV_CAP_DRM: + return udevProcessDRMDevice(device, def); ++ case VIR_NODE_DEV_CAP_MDEV: ++ case VIR_NODE_DEV_CAP_MDEV_TYPES: + case VIR_NODE_DEV_CAP_SYSTEM: + case VIR_NODE_DEV_CAP_FC_HOST: + case VIR_NODE_DEV_CAP_VPORTS: +diff --git a/tools/virsh-nodedev.c b/tools/virsh-nodedev.c +index c69144021..ad96dda1f 100644 +--- a/tools/virsh-nodedev.c ++++ b/tools/virsh-nodedev.c +@@ -454,6 +454,12 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) + case VIR_NODE_DEV_CAP_DRM: + flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM; + break; ++ case VIR_NODE_DEV_CAP_MDEV_TYPES: ++ flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES; ++ break; ++ case VIR_NODE_DEV_CAP_MDEV: ++ flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV; ++ break; + case VIR_NODE_DEV_CAP_LAST: + break; + } +-- +2.13.0 + diff --git a/SOURCES/libvirt-nodedev-Introduce-the-mdev-capability-to-a-PCI-parent-device.patch b/SOURCES/libvirt-nodedev-Introduce-the-mdev-capability-to-a-PCI-parent-device.patch new file mode 100644 index 0000000..32d38c3 --- /dev/null +++ b/SOURCES/libvirt-nodedev-Introduce-the-mdev-capability-to-a-PCI-parent-device.patch @@ -0,0 +1,522 @@ +From 909d3ff4c0e4ab7486c60dade9900462c896d3ba Mon Sep 17 00:00:00 2001 +Message-Id: <909d3ff4c0e4ab7486c60dade9900462c896d3ba@dist-git> +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:53 +0200 +Subject: [PATCH] nodedev: Introduce the mdev capability to a PCI parent device + +The parent device needs to report the generic stuff about the supported +mediated devices types, like device API, available instances, type name, +etc. Therefore this patch introduces a new nested capability element of +type 'mdev_types' with the resulting XML of the following format: + + + ... + + ... + + + optional_vendor_supplied_codename + vfio-pci + NUM + + ... + + ... + + + + ... + + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit 500cbc066a5362834462c4eefb260b7c96a8554f) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + docs/schemas/nodedev.rng | 26 +++++ + src/conf/node_device_conf.c | 101 +++++++++++++++++ + src/conf/node_device_conf.h | 15 +++ + src/conf/virnodedeviceobj.c | 20 +++- + src/libvirt_private.syms | 1 + + src/node_device/node_device_udev.c | 119 +++++++++++++++++++++ + .../pci_0000_02_10_7_mdev_types.xml | 32 ++++++ + tests/nodedevxml2xmltest.c | 1 + + 8 files changed, 313 insertions(+), 2 deletions(-) + create mode 100644 tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml + +diff --git a/docs/schemas/nodedev.rng b/docs/schemas/nodedev.rng +index 0f90a73c8..e0a2c5032 100644 +--- a/docs/schemas/nodedev.rng ++++ b/docs/schemas/nodedev.rng +@@ -205,6 +205,32 @@ + + + ++ ++ ++ mdev_types ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ vfio-pci ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ + + + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 90a087a37..de8ba8f9d 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -89,6 +89,19 @@ virNodeDevCapsDefParseString(const char *xpath, + + + void ++virNodeDevCapMdevTypeFree(virNodeDevCapMdevTypePtr type) ++{ ++ if (!type) ++ return; ++ ++ VIR_FREE(type->id); ++ VIR_FREE(type->name); ++ VIR_FREE(type->device_api); ++ VIR_FREE(type); ++} ++ ++ ++void + virNodeDeviceDefFree(virNodeDeviceDefPtr def) + { + virNodeDevCapsDefPtr caps; +@@ -265,6 +278,27 @@ virNodeDeviceCapPCIDefFormat(virBufferPtr buf, + virBufferAsprintf(buf, "\n", + virPCIHeaderTypeToString(data->pci_dev.hdrType)); + } ++ if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) { ++ virBufferAddLit(buf, "\n"); ++ virBufferAdjustIndent(buf, 2); ++ for (i = 0; i < data->pci_dev.nmdev_types; i++) { ++ virNodeDevCapMdevTypePtr type = data->pci_dev.mdev_types[i]; ++ virBufferEscapeString(buf, "\n", type->id); ++ virBufferAdjustIndent(buf, 2); ++ if (type->name) ++ virBufferEscapeString(buf, "%s\n", ++ type->name); ++ virBufferEscapeString(buf, "%s\n", ++ type->device_api); ++ virBufferAsprintf(buf, ++ "%u\n", ++ type->available_instances); ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } ++ virBufferAdjustIndent(buf, -2); ++ virBufferAddLit(buf, "\n"); ++ } + if (data->pci_dev.nIommuGroupDevices) { + virBufferAsprintf(buf, "\n", + data->pci_dev.iommuGroupNumber); +@@ -1365,6 +1399,67 @@ virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt, + + + static int ++virNodeDevPCICapMdevTypesParseXML(xmlXPathContextPtr ctxt, ++ virNodeDevCapPCIDevPtr pci_dev) ++{ ++ int ret = -1; ++ xmlNodePtr orignode = NULL; ++ xmlNodePtr *nodes = NULL; ++ int nmdev_types = -1; ++ virNodeDevCapMdevTypePtr type = NULL; ++ size_t i; ++ ++ if ((nmdev_types = virXPathNodeSet("./type", ctxt, &nodes)) < 0) ++ goto cleanup; ++ ++ orignode = ctxt->node; ++ for (i = 0; i < nmdev_types; i++) { ++ ctxt->node = nodes[i]; ++ ++ if (VIR_ALLOC(type) < 0) ++ goto cleanup; ++ ++ if (!(type->id = virXPathString("string(./@id[1])", ctxt))) { ++ virReportError(VIR_ERR_XML_ERROR, "%s", ++ _("missing 'id' attribute for mediated device's " ++ " element")); ++ goto cleanup; ++ } ++ ++ if (!(type->device_api = virXPathString("string(./deviceAPI[1])", ctxt))) { ++ virReportError(VIR_ERR_XML_ERROR, ++ _("missing device API for mediated device type '%s'"), ++ type->id); ++ goto cleanup; ++ } ++ ++ if (virXPathUInt("number(./availableInstances)", ctxt, ++ &type->available_instances) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, ++ _("missing number of available instances for " ++ "mediated device type '%s'"), ++ type->id); ++ goto cleanup; ++ } ++ ++ type->name = virXPathString("string(./name)", ctxt); ++ ++ if (VIR_APPEND_ELEMENT(pci_dev->mdev_types, ++ pci_dev->nmdev_types, type) < 0) ++ goto cleanup; ++ } ++ ++ pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; ++ ret = 0; ++ cleanup: ++ VIR_FREE(nodes); ++ virNodeDevCapMdevTypeFree(type); ++ ctxt->node = orignode; ++ return ret; ++} ++ ++ ++static int + virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapPCIDevPtr pci_dev) +@@ -1386,6 +1481,9 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, + } else if (STREQ(type, "virt_functions") && + virNodeDevPCICapSRIOVVirtualParseXML(ctxt, pci_dev) < 0) { + goto cleanup; ++ } else if (STREQ(type, "mdev_types") && ++ virNodeDevPCICapMdevTypesParseXML(ctxt, pci_dev) < 0) { ++ goto cleanup; + } else { + int hdrType = virPCIHeaderTypeFromString(type); + +@@ -1898,6 +1996,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) + VIR_FREE(data->pci_dev.iommuGroupDevices[i]); + VIR_FREE(data->pci_dev.iommuGroupDevices); + virPCIEDeviceInfoFree(data->pci_dev.pci_express); ++ for (i = 0; i < data->pci_dev.nmdev_types; i++) ++ virNodeDevCapMdevTypeFree(data->pci_dev.mdev_types[i]); ++ VIR_FREE(data->pci_dev.mdev_types); + break; + case VIR_NODE_DEV_CAP_USB_DEV: + VIR_FREE(data->usb_dev.product_name); +diff --git a/src/conf/node_device_conf.h b/src/conf/node_device_conf.h +index e168f2e27..18aaff8b5 100644 +--- a/src/conf/node_device_conf.h ++++ b/src/conf/node_device_conf.h +@@ -95,6 +95,7 @@ typedef enum { + VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION = (1 << 0), + VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION = (1 << 1), + VIR_NODE_DEV_CAP_FLAG_PCIE = (1 << 2), ++ VIR_NODE_DEV_CAP_FLAG_PCI_MDEV = (1 << 3), + } virNodeDevPCICapFlags; + + typedef enum { +@@ -133,6 +134,15 @@ struct _virNodeDevCapSystem { + virNodeDevCapSystemFirmware firmware; + }; + ++typedef struct _virNodeDevCapMdevType virNodeDevCapMdevType; ++typedef virNodeDevCapMdevType *virNodeDevCapMdevTypePtr; ++struct _virNodeDevCapMdevType { ++ char *id; ++ char *name; ++ char *device_api; ++ unsigned int available_instances; ++}; ++ + typedef struct _virNodeDevCapPCIDev virNodeDevCapPCIDev; + typedef virNodeDevCapPCIDev *virNodeDevCapPCIDevPtr; + struct _virNodeDevCapPCIDev { +@@ -156,6 +166,8 @@ struct _virNodeDevCapPCIDev { + int numa_node; + virPCIEDeviceInfoPtr pci_express; + int hdrType; /* enum virPCIHeaderType or -1 */ ++ virNodeDevCapMdevTypePtr *mdev_types; ++ size_t nmdev_types; + }; + + typedef struct _virNodeDevCapUSBDev virNodeDevCapUSBDev; +@@ -340,6 +352,9 @@ virNodeDeviceDefFree(virNodeDeviceDefPtr def); + void + virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps); + ++void ++virNodeDevCapMdevTypeFree(virNodeDevCapMdevTypePtr type); ++ + # define VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP \ + (VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM | \ + VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV | \ +diff --git a/src/conf/virnodedeviceobj.c b/src/conf/virnodedeviceobj.c +index 21d5d3f75..ac25fb598 100644 +--- a/src/conf/virnodedeviceobj.c ++++ b/src/conf/virnodedeviceobj.c +@@ -42,11 +42,13 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *dev, + virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_FC_HOST); + const char *vports_cap = + virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_VPORTS); ++ const char *mdev_types = ++ virNodeDevCapTypeToString(VIR_NODE_DEV_CAP_MDEV_TYPES); + + while (caps) { +- if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type))) ++ if (STREQ(cap, virNodeDevCapTypeToString(caps->data.type))) { + return 1; +- else if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) ++ } else if (caps->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) { + if ((STREQ(cap, fc_host_cap) && + (caps->data.scsi_host.flags & + VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST)) || +@@ -54,6 +56,13 @@ virNodeDeviceObjHasCap(const virNodeDeviceObj *dev, + (caps->data.scsi_host.flags & + VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS))) + return 1; ++ } else if (caps->data.type == VIR_NODE_DEV_CAP_PCI_DEV) { ++ if ((STREQ(cap, mdev_types)) && ++ (caps->data.pci_dev.flags & ++ VIR_NODE_DEV_CAP_FLAG_PCI_MDEV)) ++ return 1; ++ } ++ + caps = caps->next; + } + return 0; +@@ -468,6 +477,13 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj, + VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS)) + return true; + } ++ ++ if (cap->data.type == VIR_NODE_DEV_CAP_PCI_DEV) { ++ if (type == VIR_NODE_DEV_CAP_MDEV_TYPES && ++ (cap->data.pci_dev.flags & ++ VIR_NODE_DEV_CAP_FLAG_PCI_MDEV)) ++ return true; ++ } + } + + return false; +diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms +index 7e1a06db3..343966cd0 100644 +--- a/src/libvirt_private.syms ++++ b/src/libvirt_private.syms +@@ -692,6 +692,7 @@ virNetDevIPRouteParseXML; + + + # conf/node_device_conf.h ++virNodeDevCapMdevTypeFree; + virNodeDevCapsDefFree; + virNodeDevCapTypeFromString; + virNodeDevCapTypeToString; +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index d4489e2a5..b89099c82 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -314,6 +314,119 @@ static int udevTranslatePCIIds(unsigned int vendor, + } + + ++static int ++udevFillMdevType(struct udev_device *device, ++ const char *dir, ++ virNodeDevCapMdevTypePtr type) ++{ ++ int ret = -1; ++ char *attrpath = NULL; ++ ++#define MDEV_GET_SYSFS_ATTR(attr_name, cb, ...) \ ++ do { \ ++ if (virAsprintf(&attrpath, "%s/%s", dir, #attr_name) < 0) \ ++ goto cleanup; \ ++ \ ++ if (cb(device, attrpath, __VA_ARGS__) < 0) \ ++ goto cleanup; \ ++ \ ++ VIR_FREE(attrpath); \ ++ } while (0) \ ++ ++ if (VIR_STRDUP(type->id, last_component(dir)) < 0) ++ goto cleanup; ++ ++ /* query udev for the attributes under subdirectories using the relative ++ * path stored in @dir, i.e. 'mdev_supported_types/' ++ */ ++ MDEV_GET_SYSFS_ATTR(name, udevGetStringSysfsAttr, &type->name); ++ MDEV_GET_SYSFS_ATTR(device_api, udevGetStringSysfsAttr, &type->device_api); ++ MDEV_GET_SYSFS_ATTR(available_instances, udevGetUintSysfsAttr, ++ &type->available_instances, 10); ++ ++#undef MDEV_GET_SYSFS_ATTR ++ ++ ret = 0; ++ cleanup: ++ VIR_FREE(attrpath); ++ return ret; ++} ++ ++ ++static int ++udevPCIGetMdevTypesCap(struct udev_device *device, ++ virNodeDevCapPCIDevPtr pcidata) ++{ ++ int ret = -1; ++ int dirret = -1; ++ DIR *dir = NULL; ++ struct dirent *entry; ++ char *path = NULL; ++ char *tmppath = NULL; ++ virNodeDevCapMdevTypePtr type = NULL; ++ virNodeDevCapMdevTypePtr *types = NULL; ++ size_t ntypes = 0; ++ size_t i; ++ ++ if (virAsprintf(&path, "%s/mdev_supported_types", ++ udev_device_get_syspath(device)) < 0) ++ return -1; ++ ++ if ((dirret = virDirOpenIfExists(&dir, path)) < 0) ++ goto cleanup; ++ ++ if (dirret == 0) { ++ ret = 0; ++ goto cleanup; ++ } ++ ++ if (VIR_ALLOC(types) < 0) ++ goto cleanup; ++ ++ /* UDEV doesn't report attributes under subdirectories by default but is ++ * able to query them if the path to the attribute is relative to the ++ * device's base path, e.g. /sys/devices/../0000:00:01.0/ is the device's ++ * base path as udev reports it, but we're interested in attributes under ++ * /sys/devices/../0000:00:01.0/mdev_supported_types//. So, we need to ++ * scan the subdirectories ourselves. ++ */ ++ while ((dirret = virDirRead(dir, &entry, path)) > 0) { ++ if (VIR_ALLOC(type) < 0) ++ goto cleanup; ++ ++ /* construct the relative mdev type path bit for udev */ ++ if (virAsprintf(&tmppath, "mdev_supported_types/%s", entry->d_name) < 0) ++ goto cleanup; ++ ++ if (udevFillMdevType(device, tmppath, type) < 0) ++ goto cleanup; ++ ++ if (VIR_APPEND_ELEMENT(types, ntypes, type) < 0) ++ goto cleanup; ++ ++ VIR_FREE(tmppath); ++ } ++ ++ if (dirret < 0) ++ goto cleanup; ++ ++ VIR_STEAL_PTR(pcidata->mdev_types, types); ++ pcidata->nmdev_types = ntypes; ++ pcidata->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; ++ ntypes = 0; ++ ret = 0; ++ cleanup: ++ virNodeDevCapMdevTypeFree(type); ++ for (i = 0; i < ntypes; i++) ++ virNodeDevCapMdevTypeFree(types[i]); ++ VIR_FREE(types); ++ VIR_FREE(path); ++ VIR_FREE(tmppath); ++ VIR_DIR_CLOSE(dir); ++ return ret; ++} ++ ++ + static int udevProcessPCI(struct udev_device *device, + virNodeDeviceDefPtr def) + { +@@ -404,6 +517,12 @@ static int udevProcessPCI(struct udev_device *device, + } + } + ++ /* check whether the device is mediated devices framework capable, if so, ++ * process it ++ */ ++ if (udevPCIGetMdevTypesCap(device, pci_dev) < 0) ++ goto cleanup; ++ + ret = 0; + + cleanup: +diff --git a/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml b/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml +new file mode 100644 +index 000000000..a2d57569a +--- /dev/null ++++ b/tests/nodedevschemadata/pci_0000_02_10_7_mdev_types.xml +@@ -0,0 +1,32 @@ ++ ++ pci_0000_02_10_7 ++ pci_0000_00_04_0 ++ ++ 0 ++ 2 ++ 16 ++ 7 ++ 82576 Virtual Function ++ Intel Corporation ++ ++ ++ bar1 ++ vfio-pci ++ 1 ++ ++ ++ bar2 ++ vfio-pci ++ 2 ++ ++ ++ ++
      ++ ++ ++ ++ ++ ++ ++ ++ +diff --git a/tests/nodedevxml2xmltest.c b/tests/nodedevxml2xmltest.c +index 5e1ae170c..eb5c50b86 100644 +--- a/tests/nodedevxml2xmltest.c ++++ b/tests/nodedevxml2xmltest.c +@@ -101,6 +101,7 @@ mymain(void) + DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all"); + DO_TEST("pci_0000_02_10_7_sriov_pf_vfs_all_header_type"); + DO_TEST("drm_renderD129"); ++ DO_TEST("pci_0000_02_10_7_mdev_types"); + + return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; + } +-- +2.13.0 + diff --git a/SOURCES/libvirt-nodedev-Make-use-of-the-compile-time-missing-enum-in-switch-error.patch b/SOURCES/libvirt-nodedev-Make-use-of-the-compile-time-missing-enum-in-switch-error.patch new file mode 100644 index 0000000..36c618b --- /dev/null +++ b/SOURCES/libvirt-nodedev-Make-use-of-the-compile-time-missing-enum-in-switch-error.patch @@ -0,0 +1,97 @@ +From 403371cc06cd9ac36bbe7e7a2e046de82c09e762 Mon Sep 17 00:00:00 2001 +Message-Id: <403371cc06cd9ac36bbe7e7a2e046de82c09e762@dist-git> +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:47 +0200 +Subject: [PATCH] nodedev: Make use of the compile-time missing enum in switch + error + +So udevGetDeviceDetails was one those functions using an enum in a +switch, but since it had a 'default' case, compiler didn't warn about an +unhandled enum. Moreover, the error about an unsupported device type +reported in the default case is unnecessary, since by the time we get +there, udevGetDeviceType (which was called before) already made sure +that any unrecognized device types had been handled properly. + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit 364c912cf384d2fb7575ba2f71a041297210e0e2) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + src/node_device/node_device_udev.c | 45 +++++++++++++------------------------- + 1 file changed, 15 insertions(+), 30 deletions(-) + +diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c +index bcae444d8..591da8db2 100644 +--- a/src/node_device/node_device_udev.c ++++ b/src/node_device/node_device_udev.c +@@ -1043,50 +1043,35 @@ udevGetDeviceType(struct udev_device *device, + static int udevGetDeviceDetails(struct udev_device *device, + virNodeDeviceDefPtr def) + { +- int ret = 0; +- + switch (def->caps->data.type) { +- case VIR_NODE_DEV_CAP_SYSTEM: +- /* There's no libudev equivalent of system, so ignore it. */ +- break; + case VIR_NODE_DEV_CAP_PCI_DEV: +- ret = udevProcessPCI(device, def); +- break; ++ return udevProcessPCI(device, def); + case VIR_NODE_DEV_CAP_USB_DEV: +- ret = udevProcessUSBDevice(device, def); +- break; ++ return udevProcessUSBDevice(device, def); + case VIR_NODE_DEV_CAP_USB_INTERFACE: +- ret = udevProcessUSBInterface(device, def); +- break; ++ return udevProcessUSBInterface(device, def); + case VIR_NODE_DEV_CAP_NET: +- ret = udevProcessNetworkInterface(device, def); +- break; ++ return udevProcessNetworkInterface(device, def); + case VIR_NODE_DEV_CAP_SCSI_HOST: +- ret = udevProcessSCSIHost(device, def); +- break; ++ return udevProcessSCSIHost(device, def); + case VIR_NODE_DEV_CAP_SCSI_TARGET: +- ret = udevProcessSCSITarget(device, def); +- break; ++ return udevProcessSCSITarget(device, def); + case VIR_NODE_DEV_CAP_SCSI: +- ret = udevProcessSCSIDevice(device, def); +- break; ++ return udevProcessSCSIDevice(device, def); + case VIR_NODE_DEV_CAP_STORAGE: +- ret = udevProcessStorage(device, def); +- break; ++ return udevProcessStorage(device, def); + case VIR_NODE_DEV_CAP_SCSI_GENERIC: +- ret = udevProcessSCSIGeneric(device, def); +- break; ++ return udevProcessSCSIGeneric(device, def); + case VIR_NODE_DEV_CAP_DRM: +- ret = udevProcessDRMDevice(device, def); +- break; +- default: +- virReportError(VIR_ERR_INTERNAL_ERROR, +- _("Unknown device type %d"), def->caps->data.type); +- ret = -1; ++ return udevProcessDRMDevice(device, def); ++ case VIR_NODE_DEV_CAP_SYSTEM: ++ case VIR_NODE_DEV_CAP_FC_HOST: ++ case VIR_NODE_DEV_CAP_VPORTS: ++ case VIR_NODE_DEV_CAP_LAST: + break; + } + +- return ret; ++ return 0; + } + + +-- +2.13.0 + diff --git a/SOURCES/libvirt-nodedev-conf-Split-PCI-sub-capability-parsing-to-separate-methods.patch b/SOURCES/libvirt-nodedev-conf-Split-PCI-sub-capability-parsing-to-separate-methods.patch new file mode 100644 index 0000000..9a5e2d4 --- /dev/null +++ b/SOURCES/libvirt-nodedev-conf-Split-PCI-sub-capability-parsing-to-separate-methods.patch @@ -0,0 +1,198 @@ +From 309e27ed960e7ac34177aa1fcac34cc6faf149fb Mon Sep 17 00:00:00 2001 +Message-Id: <309e27ed960e7ac34177aa1fcac34cc6faf149fb@dist-git> +From: Erik Skultety +Date: Thu, 18 May 2017 14:02:51 +0200 +Subject: [PATCH] nodedev: conf: Split PCI sub-capability parsing to separate + methods + +Since there's at least SRIOV and MDEV sub-capabilities to be parsed, +let's make the code more readable by splitting it to several logical +blocks. + +https://bugzilla.redhat.com/show_bug.cgi?id=1452072 + +Signed-off-by: Erik Skultety +(cherry picked from commit a5c1f3b7e028193e8cb9f9a420ac2fdd5f4a66fe) +Signed-off-by: Erik Skultety +Signed-off-by: Jiri Denemark +--- + src/conf/node_device_conf.c | 142 ++++++++++++++++++++++++++------------------ + 1 file changed, 83 insertions(+), 59 deletions(-) + +diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c +index 02215f32d..56a26b578 100644 +--- a/src/conf/node_device_conf.c ++++ b/src/conf/node_device_conf.c +@@ -1286,76 +1286,102 @@ virPCIEDeviceInfoParseXML(xmlXPathContextPtr ctxt, + + + static int ++virNodeDevPCICapSRIOVPhysicalParseXML(xmlXPathContextPtr ctxt, ++ virNodeDevCapPCIDevPtr pci_dev) ++{ ++ xmlNodePtr address = virXPathNode("./address[1]", ctxt); ++ ++ if (VIR_ALLOC(pci_dev->physical_function) < 0) ++ return -1; ++ ++ if (!address) { ++ virReportError(VIR_ERR_XML_ERROR, "%s", ++ _("Missing address in 'phys_function' capability")); ++ return -1; ++ } ++ ++ if (virPCIDeviceAddressParseXML(address, ++ pci_dev->physical_function) < 0) ++ return -1; ++ ++ pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; ++ ++ return 0; ++} ++ ++ ++static int ++virNodeDevPCICapSRIOVVirtualParseXML(xmlXPathContextPtr ctxt, ++ virNodeDevCapPCIDevPtr pci_dev) ++{ ++ int ret = -1; ++ xmlNodePtr *addresses = NULL; ++ int naddresses = virXPathNodeSet("./address", ctxt, &addresses); ++ char *maxFuncsStr = virXPathString("string(./@maxCount)", ctxt); ++ size_t i; ++ ++ if (naddresses < 0) ++ goto cleanup; ++ ++ if (maxFuncsStr && ++ virStrToLong_uip(maxFuncsStr, NULL, 10, ++ &pci_dev->max_virtual_functions) < 0) { ++ virReportError(VIR_ERR_XML_ERROR, "%s", ++ _("Malformed 'maxCount' parameter")); ++ goto cleanup; ++ } ++ ++ if (VIR_ALLOC_N(pci_dev->virtual_functions, naddresses) < 0) ++ goto cleanup; ++ ++ for (i = 0; i < naddresses; i++) { ++ virPCIDeviceAddressPtr addr = NULL; ++ ++ if (VIR_ALLOC(addr) < 0) ++ goto cleanup; ++ ++ if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) { ++ VIR_FREE(addr); ++ goto cleanup; ++ } ++ ++ if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, ++ pci_dev->num_virtual_functions, ++ addr) < 0) ++ goto cleanup; ++ } ++ ++ pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; ++ ret = 0; ++ cleanup: ++ VIR_FREE(addresses); ++ VIR_FREE(maxFuncsStr); ++ return ret; ++} ++ ++ ++static int + virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, + xmlNodePtr node, + virNodeDevCapPCIDevPtr pci_dev) + { +- char *maxFuncsStr = virXMLPropString(node, "maxCount"); + char *type = virXMLPropString(node, "type"); +- xmlNodePtr *addresses = NULL; + xmlNodePtr orignode = ctxt->node; + int ret = -1; +- size_t i = 0; + + ctxt->node = node; + + if (!type) { + virReportError(VIR_ERR_XML_ERROR, "%s", _("Missing capability type")); +- goto out; ++ goto cleanup; + } + +- if (STREQ(type, "phys_function")) { +- xmlNodePtr address = virXPathNode("./address[1]", ctxt); +- +- if (VIR_ALLOC(pci_dev->physical_function) < 0) +- goto out; +- +- if (!address) { +- virReportError(VIR_ERR_XML_ERROR, "%s", +- _("Missing address in 'phys_function' capability")); +- goto out; +- } +- +- if (virPCIDeviceAddressParseXML(address, +- pci_dev->physical_function) < 0) +- goto out; +- +- pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION; +- } else if (STREQ(type, "virt_functions")) { +- int naddresses; +- +- if ((naddresses = virXPathNodeSet("./address", ctxt, &addresses)) < 0) +- goto out; +- +- if (maxFuncsStr && +- virStrToLong_uip(maxFuncsStr, NULL, 10, +- &pci_dev->max_virtual_functions) < 0) { +- virReportError(VIR_ERR_XML_ERROR, "%s", +- _("Malformed 'maxCount' parameter")); +- goto out; +- } +- +- if (VIR_ALLOC_N(pci_dev->virtual_functions, naddresses) < 0) +- goto out; +- +- for (i = 0; i < naddresses; i++) { +- virPCIDeviceAddressPtr addr = NULL; +- +- if (VIR_ALLOC(addr) < 0) +- goto out; +- +- if (virPCIDeviceAddressParseXML(addresses[i], addr) < 0) { +- VIR_FREE(addr); +- goto out; +- } +- +- if (VIR_APPEND_ELEMENT(pci_dev->virtual_functions, +- pci_dev->num_virtual_functions, +- addr) < 0) +- goto out; +- } +- +- pci_dev->flags |= VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION; ++ if (STREQ(type, "phys_function") && ++ virNodeDevPCICapSRIOVPhysicalParseXML(ctxt, pci_dev) < 0) { ++ goto cleanup; ++ } else if (STREQ(type, "virt_functions") && ++ virNodeDevPCICapSRIOVVirtualParseXML(ctxt, pci_dev) < 0) { ++ goto cleanup; + } else { + int hdrType = virPCIHeaderTypeFromString(type); + +@@ -1364,9 +1390,7 @@ virNodeDevPCICapabilityParseXML(xmlXPathContextPtr ctxt, + } + + ret = 0; +- out: +- VIR_FREE(addresses); +- VIR_FREE(maxFuncsStr); ++ cleanup: + VIR_FREE(type); + ctxt->node = orignode; + return ret; +-- +2.13.0 + diff --git a/SOURCES/libvirt-pci-fix-link-maximum-speed-detection.patch b/SOURCES/libvirt-pci-fix-link-maximum-speed-detection.patch new file mode 100644 index 0000000..928b70b --- /dev/null +++ b/SOURCES/libvirt-pci-fix-link-maximum-speed-detection.patch @@ -0,0 +1,39 @@ +From e971b5b913bc215ffb82419ae3db24a17ea094e8 Mon Sep 17 00:00:00 2001 +Message-Id: +From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= + +Date: Wed, 24 May 2017 12:56:09 -0400 +Subject: [PATCH] pci: fix link maximum speed detection +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Commit 8e09663 "pci: recognize/report GEN4 (PCIe 4.0) card 16GT/s Link +speed" introduced another speed into enum, but mistakenly also altered +field width, so one bit of link width was included there. + +Resolves: https://bugzilla.redhat.com/1455017 + +Signed-off-by: Marek Marczykowski-Górecki +(cherry picked from commit 1128769f9ee50bb250333a5a5d276afbe74711ea) +Signed-off-by: Jiri Denemark +--- + src/util/virpci.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/util/virpci.c b/src/util/virpci.c +index c89b94b5f..a2db65d7d 100644 +--- a/src/util/virpci.c ++++ b/src/util/virpci.c +@@ -147,7 +147,7 @@ struct _virPCIDeviceList { + #define PCI_EXP_DEVCAP 0x4 /* Device capabilities */ + #define PCI_EXP_DEVCAP_FLR (1<<28) /* Function Level Reset */ + #define PCI_EXP_LNKCAP 0xc /* Link Capabilities */ +-#define PCI_EXP_LNKCAP_SPEED 0x0001f /* Maximum Link Speed */ ++#define PCI_EXP_LNKCAP_SPEED 0x0000f /* Maximum Link Speed */ + #define PCI_EXP_LNKCAP_WIDTH 0x003f0 /* Maximum Link Width */ + #define PCI_EXP_LNKSTA 0x12 /* Link Status */ + #define PCI_EXP_LNKSTA_SPEED 0x000f /* Negotiated Link Speed */ +-- +2.13.0 + diff --git a/SOURCES/libvirt-pci-recognize-report-GEN4-PCIe-4.0-card-16GT-s-Link-speed.patch b/SOURCES/libvirt-pci-recognize-report-GEN4-PCIe-4.0-card-16GT-s-Link-speed.patch new file mode 100644 index 0000000..843d60c --- /dev/null +++ b/SOURCES/libvirt-pci-recognize-report-GEN4-PCIe-4.0-card-16GT-s-Link-speed.patch @@ -0,0 +1,57 @@ +From 7cdf18b541dfdbbbe4ed1e35179dd41c0d473648 Mon Sep 17 00:00:00 2001 +Message-Id: <7cdf18b541dfdbbbe4ed1e35179dd41c0d473648@dist-git> +From: Shivaprasad G Bhat +Date: Mon, 17 Apr 2017 17:16:44 -0400 +Subject: [PATCH] pci: recognize/report GEN4 (PCIe 4.0) card 16GT/s Link speed + +Without this added enum value, nodedev-dumpxml of a GEN4 (PCIe 4.0) +card will fail (due to the unrecognized link speed), and since +nodedev-detach and nodedev-reattach internally do a dumpxml+parse, +they will also fail. With this patch, all those operations succeed. + +Resolves: https://bugzilla.redhat.com/1442831 + +Signed-off-by: Shivaprasad G Bhat +(cherry picked from commit 8e09663f7ff70b10a560746f17897d2c67c8460d) +--- + src/util/virpci.c | 4 ++-- + src/util/virpci.h | 1 + + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/util/virpci.c b/src/util/virpci.c +index 65c108f2e..c89b94b5f 100644 +--- a/src/util/virpci.c ++++ b/src/util/virpci.c +@@ -53,7 +53,7 @@ VIR_LOG_INIT("util.pci"); + #define PCI_ADDR_LEN 13 /* "XXXX:XX:XX.X" */ + + VIR_ENUM_IMPL(virPCIELinkSpeed, VIR_PCIE_LINK_SPEED_LAST, +- "", "2.5", "5", "8") ++ "", "2.5", "5", "8", "16") + + VIR_ENUM_IMPL(virPCIStubDriver, VIR_PCI_STUB_DRIVER_LAST, + "none", +@@ -147,7 +147,7 @@ struct _virPCIDeviceList { + #define PCI_EXP_DEVCAP 0x4 /* Device capabilities */ + #define PCI_EXP_DEVCAP_FLR (1<<28) /* Function Level Reset */ + #define PCI_EXP_LNKCAP 0xc /* Link Capabilities */ +-#define PCI_EXP_LNKCAP_SPEED 0x0000f /* Maximum Link Speed */ ++#define PCI_EXP_LNKCAP_SPEED 0x0001f /* Maximum Link Speed */ + #define PCI_EXP_LNKCAP_WIDTH 0x003f0 /* Maximum Link Width */ + #define PCI_EXP_LNKSTA 0x12 /* Link Status */ + #define PCI_EXP_LNKSTA_SPEED 0x000f /* Negotiated Link Speed */ +diff --git a/src/util/virpci.h b/src/util/virpci.h +index 8637c2c68..570684e75 100644 +--- a/src/util/virpci.h ++++ b/src/util/virpci.h +@@ -58,6 +58,7 @@ typedef enum { + VIR_PCIE_LINK_SPEED_25, + VIR_PCIE_LINK_SPEED_5, + VIR_PCIE_LINK_SPEED_8, ++ VIR_PCIE_LINK_SPEED_16, + VIR_PCIE_LINK_SPEED_LAST + } virPCIELinkSpeed; + +-- +2.12.2 + diff --git a/SOURCES/libvirt-qemu-Abstract-shmem-socket-path-preparation.patch b/SOURCES/libvirt-qemu-Abstract-shmem-socket-path-preparation.patch deleted file mode 100644 index ca6f983..0000000 --- a/SOURCES/libvirt-qemu-Abstract-shmem-socket-path-preparation.patch +++ /dev/null @@ -1,78 +0,0 @@ -From 2bcbf4e9a10d8db84c212c7815456af6996bc6e9 Mon Sep 17 00:00:00 2001 -Message-Id: <2bcbf4e9a10d8db84c212c7815456af6996bc6e9@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:41 +0100 -Subject: [PATCH] qemu: Abstract shmem socket path preparation - -Put it into qemuDomainPrepareShmemChardev() so it can be used later. -Also don't fill in the path unless the server option is enabled. - -Signed-off-by: Martin Kletzander -(cherry picked from commit 0f61d7b5f2b5d011b58386e7bf1a48f75a15e9d7) - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/qemu/qemu_command.c | 5 +---- - src/qemu/qemu_domain.c | 13 +++++++++++++ - src/qemu/qemu_domain.h | 3 +++ - 3 files changed, 17 insertions(+), 4 deletions(-) - -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index 3ebfe84..adb743b 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -8513,10 +8513,7 @@ qemuBuildShmemBackendStr(virLogManagerPtr logManager, - { - char *devstr = NULL; - -- if (!shmem->server.chr.data.nix.path && -- virAsprintf(&shmem->server.chr.data.nix.path, -- "/var/lib/libvirt/shmem-%s-sock", -- shmem->name) < 0) -+ if (qemuDomainPrepareShmemChardev(shmem) < 0) - return NULL; - - devstr = qemuBuildChrChardevStr(logManager, cmd, cfg, def, -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 8db2ed5..4f99c14 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -5993,6 +5993,19 @@ qemuDomainPrepareChannel(virDomainChrDefPtr channel, - } - - -+int -+qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem) -+{ -+ if (!shmem->server.enabled || -+ shmem->server.chr.data.nix.path) -+ return 0; -+ -+ return virAsprintf(&shmem->server.chr.data.nix.path, -+ "/var/lib/libvirt/shmem-%s-sock", -+ shmem->name); -+} -+ -+ - /** - * qemuDomainVcpuHotplugIsInOrder: - * @def: domain definition -diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h -index f94bfc9..66ffe58 100644 ---- a/src/qemu/qemu_domain.h -+++ b/src/qemu/qemu_domain.h -@@ -724,6 +724,9 @@ int qemuDomainPrepareChannel(virDomainChrDefPtr chr, - const char *domainChannelTargetDir) - ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); - -+int qemuDomainPrepareShmemChardev(virDomainShmemDefPtr shmem) -+ ATTRIBUTE_NONNULL(1); -+ - bool qemuDomainVcpuHotplugIsInOrder(virDomainDefPtr def) - ATTRIBUTE_NONNULL(1); - --- -2.10.2 - diff --git a/SOURCES/libvirt-qemu-Add-capabilities-for-ivshmem-plain-doorbell.patch b/SOURCES/libvirt-qemu-Add-capabilities-for-ivshmem-plain-doorbell.patch deleted file mode 100644 index 1b44c3c..0000000 --- a/SOURCES/libvirt-qemu-Add-capabilities-for-ivshmem-plain-doorbell.patch +++ /dev/null @@ -1,134 +0,0 @@ -From 444d00e9ead63e1bd96a2ba36fa678dbcaf9c6c2 Mon Sep 17 00:00:00 2001 -Message-Id: <444d00e9ead63e1bd96a2ba36fa678dbcaf9c6c2@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:51 +0100 -Subject: [PATCH] qemu: Add capabilities for ivshmem-{plain, doorbell} - -Signed-off-by: Martin Kletzander -(cherry picked from commit 22d94ca46d797a7e7abd61134ad4490bf196baf5) - - Conflicts (due to bunch of other capabilities): - src/qemu/qemu_capabilities.c - src/qemu/qemu_capabilities.h - tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml - tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml - tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml - tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml - tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/qemu/qemu_capabilities.c | 4 ++++ - src/qemu/qemu_capabilities.h | 2 ++ - tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml | 2 ++ - tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml | 2 ++ - tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml | 2 ++ - tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml | 2 ++ - tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 2 ++ - 7 files changed, 16 insertions(+) - -diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c -index 2c49109..e511b8e 100644 ---- a/src/qemu/qemu_capabilities.c -+++ b/src/qemu/qemu_capabilities.c -@@ -342,6 +342,8 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, - "query-hotpluggable-cpus", - - "virtio-net.rx_queue_size", /* 235 */ -+ "ivshmem-plain", -+ "ivshmem-doorbell", - ); - - -@@ -1563,6 +1565,8 @@ struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = { - { "pxb-pcie", QEMU_CAPS_DEVICE_PXB_PCIE }, - { "tls-creds-x509", QEMU_CAPS_OBJECT_TLS_CREDS_X509 }, - { "intel-iommu", QEMU_CAPS_DEVICE_INTEL_IOMMU }, -+ { "ivshmem-plain", QEMU_CAPS_DEVICE_IVSHMEM_PLAIN }, -+ { "ivshmem-doorbell", QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL }, - }; - - static struct virQEMUCapsStringFlags virQEMUCapsObjectPropsVirtioBalloon[] = { -diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h -index 6949ec8..f6f624d 100644 ---- a/src/qemu/qemu_capabilities.h -+++ b/src/qemu/qemu_capabilities.h -@@ -376,6 +376,8 @@ typedef enum { - - /* 235 */ - QEMU_CAPS_VIRTIO_NET_RX_QUEUE_SIZE, /* virtio-net-*.rx_queue_size */ -+ QEMU_CAPS_DEVICE_IVSHMEM_PLAIN, /* -device ivshmem-plain */ -+ QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL, /* -device ivshmem-doorbell */ - - QEMU_CAPS_LAST /* this must always be the last item */ - } virQEMUCapsFlags; -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml -index 7586269..63b9a30 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml -@@ -157,6 +157,8 @@ - - - -+ -+ - 2005094 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml -index cc146f6..e2f01ec 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml -@@ -157,6 +157,8 @@ - - - -+ -+ - 2005094 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml -index cf77e92..d10a604 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0.ppc64le.xml -@@ -151,6 +151,8 @@ - - - -+ -+ - 2005094 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -index 5a2512e..70bf9f4 100644 ---- a/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.6.0.x86_64.xml -@@ -194,6 +194,8 @@ - - - -+ -+ - 2006000 - 0 - -diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml -index 8f878fe..78bbaf8 100644 ---- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml -@@ -192,6 +192,8 @@ - - - -+ -+ - 2006091 - 0 - (v2.7.0-rc1-52-g42e0d60) --- -2.10.2 - diff --git a/SOURCES/libvirt-qemu-Add-capability-for-query-hotpluggable-cpus-command.patch b/SOURCES/libvirt-qemu-Add-capability-for-query-hotpluggable-cpus-command.patch deleted file mode 100644 index c8de94b..0000000 --- a/SOURCES/libvirt-qemu-Add-capability-for-query-hotpluggable-cpus-command.patch +++ /dev/null @@ -1,63 +0,0 @@ -From 5872dbc70ce1acf41445442c13703f22bc2d2c9b Mon Sep 17 00:00:00 2001 -Message-Id: <5872dbc70ce1acf41445442c13703f22bc2d2c9b@dist-git> -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:11:19 -0400 -Subject: [PATCH] qemu: Add capability for query-hotpluggable-cpus command - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -(cherry picked from commit f17ddfeee39858b98ae195ac1639645748a80e6f) ---- - src/qemu/qemu_capabilities.c | 2 ++ - src/qemu/qemu_capabilities.h | 1 + - tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml | 1 + - 3 files changed, 4 insertions(+) - -diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c -index 49ad9df..ffd54c5 100644 ---- a/src/qemu/qemu_capabilities.c -+++ b/src/qemu/qemu_capabilities.c -@@ -339,6 +339,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, - "tls-creds-x509", /* 230 */ - "intel-iommu", - "smm", -+ "query-hotpluggable-cpus", - ); - - -@@ -1457,6 +1458,7 @@ struct virQEMUCapsStringFlags virQEMUCapsCommands[] = { - { "__com.redhat_change-backing-file", QEMU_CAPS_CHANGE_BACKING_FILE }, - { "rtc-reset-reinjection", QEMU_CAPS_RTC_RESET_REINJECTION }, - { "migrate-incoming", QEMU_CAPS_INCOMING_DEFER }, -+ { "query-hotpluggable-cpus", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS }, - }; - - struct virQEMUCapsStringFlags virQEMUCapsMigration[] = { -diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h -index ac1593d..68d1ea8 100644 ---- a/src/qemu/qemu_capabilities.h -+++ b/src/qemu/qemu_capabilities.h -@@ -372,6 +372,7 @@ typedef enum { - QEMU_CAPS_OBJECT_TLS_CREDS_X509, /* -object tls-creds-x509 */ - QEMU_CAPS_DEVICE_INTEL_IOMMU, /* -device intel-iommu */ - QEMU_CAPS_MACHINE_SMM_OPT, /* -machine xxx,smm=on/off/auto */ -+ QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS, /* qmp command query-hotpluggable-cpus */ - - QEMU_CAPS_LAST /* this must always be the last item */ - } virQEMUCapsFlags; -diff --git a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml -index 8fb66d2..0f3c17a 100644 ---- a/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml -+++ b/tests/qemucapabilitiesdata/caps_2.7.0.x86_64.xml -@@ -191,6 +191,7 @@ - - - -+ - 2006091 - 0 - (v2.7.0-rc1-52-g42e0d60) --- -2.10.0 - diff --git a/SOURCES/libvirt-qemu-Add-cpu-ID-to-the-vCPU-pid-list-in-the-status-XML.patch b/SOURCES/libvirt-qemu-Add-cpu-ID-to-the-vCPU-pid-list-in-the-status-XML.patch deleted file mode 100644 index 6f649b2..0000000 --- a/SOURCES/libvirt-qemu-Add-cpu-ID-to-the-vCPU-pid-list-in-the-status-XML.patch +++ /dev/null @@ -1,76 +0,0 @@ -From b6f5a9033bbed6d3b4567544b7f6556c7b4e1861 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Peter Krempa -Date: Wed, 24 Aug 2016 16:10:51 -0400 -Subject: [PATCH] qemu: Add cpu ID to the vCPU pid list in the status XML - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Note the vcpu ID so that once we allow non-contiguous vCPU topologies it -will be possible to pair thread id's with the vcpus. - -(cherry picked from commit 3f57ce4a7675958c4c0f6aaddfbc2e3c2e8473da) ---- - src/qemu/qemu_domain.c | 13 ++++++++++++- - tests/qemuxml2xmltest.c | 3 ++- - 2 files changed, 14 insertions(+), 2 deletions(-) - -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 01f0d6a..c27129e 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -1368,7 +1368,7 @@ qemuDomainObjPrivateXMLFormatVcpus(virBufferPtr buf, - virBufferAdjustIndent(buf, 2); - - for (i = 0; i < nvcpupids; i++) -- virBufferAsprintf(buf, "\n", vcpupids[i]); -+ virBufferAsprintf(buf, "\n", i, vcpupids[i]); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); -@@ -1497,9 +1497,19 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, - unsigned int idx, - qemuDomainObjPrivatePtr priv) - { -+ char *idstr; - char *pidstr; - int ret = -1; - -+ if ((idstr = virXMLPropString(node, "id"))) { -+ if (virStrToLong_uip(idstr, NULL, 10, &idx) < 0 || -+ idx >= priv->nvcpupids) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ _("invalid vcpu index '%s'"), idstr); -+ goto cleanup; -+ } -+ } -+ - if (!(pidstr = virXMLPropString(node, "pid"))) - goto cleanup; - -@@ -1509,6 +1519,7 @@ qemuDomainObjPrivateXMLParseVcpu(xmlNodePtr node, - ret = 0; - - cleanup: -+ VIR_FREE(idstr); - VIR_FREE(pidstr); - return ret; - } -diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c -index 573899f..639494b 100644 ---- a/tests/qemuxml2xmltest.c -+++ b/tests/qemuxml2xmltest.c -@@ -113,7 +113,8 @@ testGetStatuXMLPrefixVcpus(virBufferPtr buf, - virBufferAdjustIndent(buf, 2); - - while ((vcpuid = virBitmapNextSetBit(data->activeVcpus, vcpuid)) >= 0) -- virBufferAsprintf(buf, "\n", vcpuid + 3803519); -+ virBufferAsprintf(buf, "\n", -+ vcpuid, vcpuid + 3803519); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); --- -2.10.0 - diff --git a/SOURCES/libvirt-qemu-Add-device-id-for-mediated-devices-on-qemu-command-line.patch b/SOURCES/libvirt-qemu-Add-device-id-for-mediated-devices-on-qemu-command-line.patch new file mode 100644 index 0000000..939482a --- /dev/null +++ b/SOURCES/libvirt-qemu-Add-device-id-for-mediated-devices-on-qemu-command-line.patch @@ -0,0 +1,47 @@ +From 23a4263e7611fa3f1e69f5bab7056a85e48d6b23 Mon Sep 17 00:00:00 2001 +Message-Id: <23a4263e7611fa3f1e69f5bab7056a85e48d6b23@dist-git> +From: Erik Skultety +Date: Tue, 4 Apr 2017 08:54:51 +0200 +Subject: [PATCH] qemu: Add device id for mediated devices on qemu command line + +Like all devices, add the 'id' option for mdevs as well. Patch also +adjusts the test accordingly. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1438431 + +(cherry picked from commit c3272e5e12e0bfd43b8101b73ae13d264c13337f) +Signed-off-by: Erik Skultety +--- + src/qemu/qemu_command.c | 3 ++- + tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args | 2 +- + 2 files changed, 3 insertions(+), 2 deletions(-) + +diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c +index 1a2984e56..59fedaaaf 100644 +--- a/src/qemu/qemu_command.c ++++ b/src/qemu/qemu_command.c +@@ -5231,7 +5231,8 @@ qemuBuildHostdevMediatedDevStr(const virDomainDef *def, + char *ret = NULL; + + virBufferAddLit(&buf, "vfio-pci"); +- virBufferAsprintf(&buf, ",sysfsdev=%s", ++ virBufferAsprintf(&buf, ",id=%s,sysfsdev=%s", ++ dev->info->alias, + virMediatedDeviceGetSysfsPath(mdevsrc->uuidstr)); + + if (qemuBuildDeviceAddressStr(&buf, def, dev->info, qemuCaps) < 0) +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args +index fdefeb610..76e77707b 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-mdev-precreated.args +@@ -20,6 +20,6 @@ QEMU_AUDIO_DRV=none \ + -usb \ + -drive file=/dev/HostVG/QEMUGuest2,format=raw,if=none,id=drive-ide0-0-0 \ + -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ +--device vfio-pci,\ ++-device vfio-pci,id=hostdev0,\ + sysfsdev=/sys/bus/mdev/devices/53764d0e-85a0-42b4-af5c-2046b460b1dc,bus=pci.0,\ + addr=0x3 +-- +2.12.2 + diff --git a/SOURCES/libvirt-qemu-Add-luks-support-for-domain-disk.patch b/SOURCES/libvirt-qemu-Add-luks-support-for-domain-disk.patch deleted file mode 100644 index 6039139..0000000 --- a/SOURCES/libvirt-qemu-Add-luks-support-for-domain-disk.patch +++ /dev/null @@ -1,409 +0,0 @@ -From a1901b36addfb7a064a5d451e1cfb47d5737c8eb Mon Sep 17 00:00:00 2001 -Message-Id: -From: John Ferlan -Date: Mon, 25 Jul 2016 12:43:00 -0400 -Subject: [PATCH] qemu: Add luks support for domain disk - -Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1301021 - -Generate the luks command line using the AES secret key to encrypt the -luks secret. A luks secret object will be in addition to a an AES secret. - -For hotplug, check if the encinfo exists and if so, add the AES secret -for the passphrase for the secret object used to decrypt the device. - -Modify/augment the fakeSecret* in qemuxml2argvtest in order to handle -find a uuid or a volume usage with a specific path prefix in the XML -(corresponds to the already generated XML tests). Add error message -when the 'usageID' is not 'mycluster_myname'. Commit id '1d632c39' -altered the error message generation to rely on the errors from the -secret_driver (or it's faked replacement). - -Add the .args output for adding the LUKS disk to the domain - -Signed-off-by: John Ferlan -(cherry picked from commit da86c6c22674ccc147224afa2740e33d8cbdbf22) - -NB: The .args output was modified from upstream since the downstream - does not contain commit id 'e114b09157b7fcca12b218b531debfbc0c3a09d7' - which adds ",sockets=1,cores=1,threads=1" to the "-smp 1" on the - command line - -Signed-off-by: John Ferlan ---- - src/qemu/qemu_command.c | 9 +++ - src/qemu/qemu_domain.c | 25 +++++++- - src/qemu/qemu_hotplug.c | 68 ++++++++++++++++++++++ - .../qemuxml2argvdata/qemuxml2argv-luks-disks.args | 36 ++++++++++++ - tests/qemuxml2argvtest.c | 24 +++++++- - 5 files changed, 156 insertions(+), 6 deletions(-) - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args - -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index 0ee1d34..6c91e53 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -1087,6 +1087,7 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, - int actualType = virStorageSourceGetActualType(disk->src); - qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo; -+ qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo; - bool emitDeviceSyntax = qemuDiskBusNeedsDeviceArg(disk->bus); - - if (idx < 0) { -@@ -1226,6 +1227,10 @@ qemuBuildDriveStr(virDomainDiskDefPtr disk, - secinfo->s.aes.alias); - } - -+ if (encinfo) -+ virQEMUBuildLuksOpts(&opt, &disk->src->encryption->encinfo, -+ encinfo->s.aes.alias); -+ - if (disk->src->format > 0 && - disk->src->type != VIR_STORAGE_TYPE_DIR) - virBufferAsprintf(&opt, "format=%s,", -@@ -1928,6 +1933,7 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, - virDomainDiskDefPtr disk = def->disks[i]; - qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - qemuDomainSecretInfoPtr secinfo = diskPriv->secinfo; -+ qemuDomainSecretInfoPtr encinfo = diskPriv->encinfo; - - /* PowerPC pseries based VMs do not support floppy device */ - if (disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && -@@ -1956,6 +1962,9 @@ qemuBuildDiskDriveCommandLine(virCommandPtr cmd, - if (qemuBuildDiskSecinfoCommandLine(cmd, secinfo) < 0) - return -1; - -+ if (qemuBuildDiskSecinfoCommandLine(cmd, encinfo) < 0) -+ return -1; -+ - virCommandAddArg(cmd, "-drive"); - - optstr = qemuBuildDriveStr(disk, -diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index 27158f4..26d0d12 100644 ---- a/src/qemu/qemu_domain.c -+++ b/src/qemu/qemu_domain.c -@@ -946,7 +946,8 @@ qemuDomainSecretSetup(virConnectPtr conn, - { - if (virCryptoHaveCipher(VIR_CRYPTO_CIPHER_AES256CBC) && - virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) && -- secretUsageType == VIR_SECRET_USAGE_TYPE_CEPH) { -+ (secretUsageType == VIR_SECRET_USAGE_TYPE_CEPH || -+ secretUsageType == VIR_SECRET_USAGE_TYPE_VOLUME)) { - if (qemuDomainSecretAESSetup(conn, priv, secinfo, srcalias, - secretUsageType, username, - seclookupdef, isLuks) < 0) -@@ -1006,11 +1007,14 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, - virDomainDiskDefPtr disk) - { - virStorageSourcePtr src = disk->src; -+ qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - qemuDomainSecretInfoPtr secinfo = NULL; - -- if (conn && qemuDomainSecretDiskCapable(src)) { -+ if (!conn) -+ return 0; -+ -+ if (qemuDomainSecretDiskCapable(src)) { - virSecretUsageType secretUsageType = VIR_SECRET_USAGE_TYPE_ISCSI; -- qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); - - if (VIR_ALLOC(secinfo) < 0) - return -1; -@@ -1026,6 +1030,21 @@ qemuDomainSecretDiskPrepare(virConnectPtr conn, - diskPriv->secinfo = secinfo; - } - -+ if (!virStorageSourceIsEmpty(src) && src->encryption && -+ src->format == VIR_STORAGE_FILE_LUKS) { -+ -+ if (VIR_ALLOC(secinfo) < 0) -+ return -1; -+ -+ if (qemuDomainSecretSetup(conn, priv, secinfo, disk->info.alias, -+ VIR_SECRET_USAGE_TYPE_VOLUME, NULL, -+ &src->encryption->secrets[0]->seclookupdef, -+ true) < 0) -+ goto error; -+ -+ diskPriv->encinfo = secinfo; -+ } -+ - return 0; - - error: -diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c -index 9cb1d44..6509867 100644 ---- a/src/qemu/qemu_hotplug.c -+++ b/src/qemu/qemu_hotplug.c -@@ -312,11 +312,14 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - bool releaseaddr = false; - bool driveAdded = false; - bool secobjAdded = false; -+ bool encobjAdded = false; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - const char *src = virDomainDiskGetSource(disk); - virJSONValuePtr secobjProps = NULL; -+ virJSONValuePtr encobjProps = NULL; - qemuDomainDiskPrivatePtr diskPriv; - qemuDomainSecretInfoPtr secinfo; -+ qemuDomainSecretInfoPtr encinfo; - - if (!disk->info.type) { - if (qemuDomainMachineIsS390CCW(vm->def) && -@@ -356,6 +359,10 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - goto error; - } - -+ encinfo = diskPriv->encinfo; -+ if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0) -+ goto error; -+ - if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps))) - goto error; - -@@ -379,6 +386,15 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - } - secobjAdded = true; - -+ if (encobjProps) { -+ rv = qemuMonitorAddObject(priv->mon, "secret", encinfo->s.aes.alias, -+ encobjProps); -+ encobjProps = NULL; /* qemuMonitorAddObject consumes */ -+ if (rv < 0) -+ goto exit_monitor; -+ } -+ encobjAdded = true; -+ - if (qemuMonitorAddDrive(priv->mon, drivestr) < 0) - goto exit_monitor; - driveAdded = true; -@@ -398,6 +414,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - - cleanup: - virJSONValueFree(secobjProps); -+ virJSONValueFree(encobjProps); - qemuDomainSecretDiskDestroy(disk); - VIR_FREE(devstr); - VIR_FREE(drivestr); -@@ -413,6 +430,8 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - } - if (secobjAdded) - ignore_value(qemuMonitorDelObject(priv->mon, secinfo->s.aes.alias)); -+ if (encobjAdded) -+ ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias)); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); -@@ -570,11 +589,17 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - { - size_t i; - qemuDomainObjPrivatePtr priv = vm->privateData; -+ virErrorPtr orig_err; - char *drivestr = NULL; - char *devstr = NULL; - bool driveAdded = false; -+ bool encobjAdded = false; - int ret = -1; -+ int rv; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); -+ virJSONValuePtr encobjProps = NULL; -+ qemuDomainDiskPrivatePtr diskPriv; -+ qemuDomainSecretInfoPtr encinfo; - - if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0) - goto cleanup; -@@ -605,6 +630,11 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0) - goto error; - -+ diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); -+ encinfo = diskPriv->encinfo; -+ if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0) -+ goto error; -+ - if (!(devstr = qemuBuildDriveDevStr(vm->def, disk, 0, priv->qemuCaps))) - goto error; - -@@ -616,6 +646,15 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - - qemuDomainObjEnterMonitor(driver, vm); - -+ if (encobjProps) { -+ rv = qemuMonitorAddObject(priv->mon, "secret", encinfo->s.aes.alias, -+ encobjProps); -+ encobjProps = NULL; /* qemuMonitorAddObject consumes */ -+ if (rv < 0) -+ goto exit_monitor; -+ } -+ encobjAdded = true; -+ - if (qemuMonitorAddDrive(priv->mon, drivestr) < 0) - goto exit_monitor; - driveAdded = true; -@@ -632,6 +671,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - ret = 0; - - cleanup: -+ virJSONValueFree(encobjProps); - qemuDomainSecretDiskDestroy(disk); - VIR_FREE(devstr); - VIR_FREE(drivestr); -@@ -643,6 +683,14 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - if (driveAdded) - VIR_WARN("qemuMonitorAddDevice failed on %s (%s)", drivestr, devstr); - -+ orig_err = virSaveLastError(); -+ if (encobjAdded) -+ ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias)); -+ if (orig_err) { -+ virSetError(orig_err); -+ virFreeError(orig_err); -+ } -+ - ignore_value(qemuDomainObjExitMonitor(driver, vm)); - - virDomainAuditDisk(vm, NULL, disk->src, "attach", false); -@@ -2856,6 +2904,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, - qemuDomainObjPrivatePtr priv = vm->privateData; - char *drivestr; - char *objAlias = NULL; -+ char *encAlias = NULL; - - VIR_DEBUG("Removing disk %s from domain %p %s", - disk->info.alias, vm, vm->def->name); -@@ -2881,6 +2930,20 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, - } - } - -+ /* Similarly, if this is possible a device using LUKS encryption, we -+ * can remove the luks object password too -+ */ -+ if (!virStorageSourceIsEmpty(disk->src) && disk->src->encryption && -+ disk->src->format == VIR_STORAGE_FILE_LUKS) { -+ -+ if (!(encAlias = -+ qemuDomainGetSecretAESAlias(disk->info.alias, true))) { -+ VIR_FREE(objAlias); -+ VIR_FREE(drivestr); -+ return -1; -+ } -+ } -+ - qemuDomainObjEnterMonitor(driver, vm); - - /* If it fails, then so be it - it was a best shot */ -@@ -2888,6 +2951,11 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, - ignore_value(qemuMonitorDelObject(priv->mon, objAlias)); - VIR_FREE(objAlias); - -+ /* If it fails, then so be it - it was a best shot */ -+ if (encAlias) -+ ignore_value(qemuMonitorDelObject(priv->mon, encAlias)); -+ VIR_FREE(encAlias); -+ - qemuMonitorDriveDel(priv->mon, drivestr); - VIR_FREE(drivestr); - if (qemuDomainObjExitMonitor(driver, vm) < 0) -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args b/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args -new file mode 100644 -index 0000000..efb5cb0 ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-luks-disks.args -@@ -0,0 +1,36 @@ -+LC_ALL=C \ -+PATH=/bin \ -+HOME=/home/test \ -+USER=test \ -+LOGNAME=test \ -+QEMU_AUDIO_DRV=none \ -+/usr/bin/qemu \ -+-name encryptdisk \ -+-S \ -+-object secret,id=masterKey0,format=raw,\ -+file=/tmp/lib/domain--1-encryptdisk/master-key.aes \ -+-M pc-i440fx-2.1 \ -+-m 1024 \ -+-smp 1 \ -+-uuid 496898a6-e6ff-f7c8-5dc2-3cf410945ee9 \ -+-nographic \ -+-nodefaults \ -+-monitor unix:/tmp/lib/domain--1-encryptdisk/monitor.sock,server,nowait \ -+-no-acpi \ -+-boot c \ -+-usb \ -+-object secret,id=virtio-disk0-luks-secret0,\ -+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ -+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ -+-drive file=/storage/guest_disks/encryptdisk,\ -+key-secret=virtio-disk0-luks-secret0,format=luks,if=none,id=drive-virtio-disk0 \ -+-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ -+id=virtio-disk0 \ -+-object secret,id=virtio-disk1-luks-secret0,\ -+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ -+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ -+-drive file=/storage/guest_disks/encryptdisk2,\ -+key-secret=virtio-disk1-luks-secret0,format=luks,if=none,id=drive-virtio-disk1 \ -+-device virtio-blk-pci,bus=pci.0,addr=0x5,drive=drive-virtio-disk1,\ -+id=virtio-disk1 \ -+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index d37d125..eddacf8 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -49,12 +49,22 @@ fakeSecretGetValue(virSecretPtr obj ATTRIBUTE_UNUSED, - - static virSecretPtr - fakeSecretLookupByUsage(virConnectPtr conn, -- int usageType ATTRIBUTE_UNUSED, -+ int usageType, - const char *usageID) - { - unsigned char uuid[VIR_UUID_BUFLEN]; -- if (STRNEQ(usageID, "mycluster_myname")) -+ if (usageType == VIR_SECRET_USAGE_TYPE_VOLUME) { -+ if (!STRPREFIX(usageID, "/storage/guest_disks/")) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ "test provided invalid volume storage prefix '%s'", -+ usageID); -+ return NULL; -+ } -+ } else if (STRNEQ(usageID, "mycluster_myname")) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, -+ "test provided incorrect usage '%s'", usageID); - return NULL; -+ } - - if (virUUIDGenerate(uuid) < 0) - return NULL; -@@ -62,10 +72,17 @@ fakeSecretLookupByUsage(virConnectPtr conn, - return virGetSecret(conn, uuid, usageType, usageID); - } - -+static virSecretPtr -+fakeSecretLookupByUUID(virConnectPtr conn, -+ const unsigned char *uuid) -+{ -+ return virGetSecret(conn, uuid, 0, ""); -+} -+ - static virSecretDriver fakeSecretDriver = { - .connectNumOfSecrets = NULL, - .connectListSecrets = NULL, -- .secretLookupByUUID = NULL, -+ .secretLookupByUUID = fakeSecretLookupByUUID, - .secretLookupByUsage = fakeSecretLookupByUsage, - .secretDefineXML = NULL, - .secretGetXMLDesc = NULL, -@@ -1362,6 +1379,7 @@ mymain(void) - - DO_TEST("encrypted-disk", NONE); - DO_TEST("encrypted-disk-usage", NONE); -+ DO_TEST("luks-disks", QEMU_CAPS_OBJECT_SECRET); - - DO_TEST("memtune", NONE); - DO_TEST("memtune-unlimited", NONE); --- -2.9.2 - diff --git a/SOURCES/libvirt-qemu-Add-migratable-parameter-to-virQEMUCapsInitCPUModel.patch b/SOURCES/libvirt-qemu-Add-migratable-parameter-to-virQEMUCapsInitCPUModel.patch new file mode 100644 index 0000000..48e7c6e --- /dev/null +++ b/SOURCES/libvirt-qemu-Add-migratable-parameter-to-virQEMUCapsInitCPUModel.patch @@ -0,0 +1,148 @@ +From 241d9b0d3945072ad74f9a0a5dcdb541cc2ad50b Mon Sep 17 00:00:00 2001 +Message-Id: <241d9b0d3945072ad74f9a0a5dcdb541cc2ad50b@dist-git> +From: Jiri Denemark +Date: Wed, 29 Mar 2017 13:33:50 +0200 +Subject: [PATCH] qemu: Add migratable parameter to virQEMUCapsInitCPUModel + +The caller can ask for a migratable CPU model by passing true for the +new parameter. + +Signed-off-by: Jiri Denemark +(cherry picked from commit 00e0cbcb567a57c7b5a145d7fd3fb662779f6bec) + +https://bugzilla.redhat.com/show_bug.cgi?id=1444421 + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_capabilities.c | 36 +++++++++++++++++++++++++----------- + src/qemu/qemu_capspriv.h | 3 ++- + tests/cputest.c | 2 +- + 3 files changed, 28 insertions(+), 13 deletions(-) + +diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c +index b71de9633..eb6b674b4 100644 +--- a/src/qemu/qemu_capabilities.c ++++ b/src/qemu/qemu_capabilities.c +@@ -3118,7 +3118,8 @@ virQEMUCapsCPUFilterFeatures(const char *name, + static int + virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, + qemuMonitorCPUModelInfoPtr modelInfo, +- virCPUDefPtr cpu) ++ virCPUDefPtr cpu, ++ bool migratable) + { + size_t i; + +@@ -3146,8 +3147,12 @@ virQEMUCapsInitCPUModelS390(virQEMUCapsPtr qemuCaps, + + if (VIR_STRDUP(feature->name, prop->name) < 0) + return -1; +- feature->policy = prop->value.boolean ? VIR_CPU_FEATURE_REQUIRE +- : VIR_CPU_FEATURE_DISABLE; ++ ++ if (!prop->value.boolean || ++ (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)) ++ feature->policy = VIR_CPU_FEATURE_DISABLE; ++ else ++ feature->policy = VIR_CPU_FEATURE_REQUIRE; + cpu->nfeatures++; + } + +@@ -3164,7 +3169,8 @@ static int + virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, + virDomainVirtType type, + qemuMonitorCPUModelInfoPtr model, +- virCPUDefPtr cpu) ++ virCPUDefPtr cpu, ++ bool migratable) + { + virCPUDataPtr data = NULL; + unsigned long long sigFamily = 0; +@@ -3185,9 +3191,13 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, + + switch (prop->type) { + case QEMU_MONITOR_CPU_PROPERTY_BOOLEAN: +- if (prop->value.boolean && +- virCPUx86DataAddFeature(data, prop->name) < 0) ++ if (!prop->value.boolean || ++ (migratable && prop->migratable == VIR_TRISTATE_BOOL_NO)) ++ continue; ++ ++ if (virCPUx86DataAddFeature(data, prop->name) < 0) + goto cleanup; ++ + break; + + case QEMU_MONITOR_CPU_PROPERTY_STRING: +@@ -3226,13 +3236,14 @@ virQEMUCapsInitCPUModelX86(virQEMUCapsPtr qemuCaps, + + /** + * Returns 0 when host CPU model provided by QEMU was filled in qemuCaps, +- * 1 when the caller should fall back to using virCapsPtr->host.cpu, ++ * 1 when the caller should fall back to other methods + * -1 on error. + */ + int + virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps, + virDomainVirtType type, +- virCPUDefPtr cpu) ++ virCPUDefPtr cpu, ++ bool migratable) + { + qemuMonitorCPUModelInfoPtr model; + int ret = 1; +@@ -3242,10 +3253,13 @@ virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps, + else + model = qemuCaps->tcgCPUModelInfo; + ++ if (migratable && model && !model->migratability) ++ return 1; ++ + if (ARCH_IS_S390(qemuCaps->arch)) +- ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu); ++ ret = virQEMUCapsInitCPUModelS390(qemuCaps, model, cpu, migratable); + else if (ARCH_IS_X86(qemuCaps->arch)) +- ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu); ++ ret = virQEMUCapsInitCPUModelX86(qemuCaps, type, model, cpu, migratable); + + if (ret == 0) + cpu->fallback = VIR_CPU_FALLBACK_FORBID; +@@ -3274,7 +3288,7 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, + cpu->match = VIR_CPU_MATCH_EXACT; + cpu->fallback = VIR_CPU_FALLBACK_ALLOW; + +- if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu)) < 0) { ++ if ((rc = virQEMUCapsInitCPUModel(qemuCaps, type, cpu, false)) < 0) { + goto error; + } else if (rc == 1) { + VIR_DEBUG("No host CPU model info from QEMU; probing host CPU directly"); +diff --git a/src/qemu/qemu_capspriv.h b/src/qemu/qemu_capspriv.h +index 61ccd4517..1baaaf334 100644 +--- a/src/qemu/qemu_capspriv.h ++++ b/src/qemu/qemu_capspriv.h +@@ -81,7 +81,8 @@ virQEMUCapsInitHostCPUModel(virQEMUCapsPtr qemuCaps, + int + virQEMUCapsInitCPUModel(virQEMUCapsPtr qemuCaps, + virDomainVirtType type, +- virCPUDefPtr cpu); ++ virCPUDefPtr cpu, ++ bool migratable); + + void + virQEMUCapsSetCPUModelInfo(virQEMUCapsPtr qemuCaps, +diff --git a/tests/cputest.c b/tests/cputest.c +index 3d3e43f16..8c07cf4f6 100644 +--- a/tests/cputest.c ++++ b/tests/cputest.c +@@ -709,7 +709,7 @@ cpuTestJSONCPUID(const void *arg) + cpu->match = VIR_CPU_MATCH_EXACT; + cpu->fallback = VIR_CPU_FALLBACK_FORBID; + +- if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu) != 0) ++ if (virQEMUCapsInitCPUModel(qemuCaps, VIR_DOMAIN_VIRT_KVM, cpu, false) != 0) + goto cleanup; + + ret = cpuTestCompareXML(data->arch, cpu, result, false); +-- +2.12.2 + diff --git a/SOURCES/libvirt-qemu-Add-qemuAssignDeviceShmemAlias-and-use-it.patch b/SOURCES/libvirt-qemu-Add-qemuAssignDeviceShmemAlias-and-use-it.patch deleted file mode 100644 index 167249f..0000000 --- a/SOURCES/libvirt-qemu-Add-qemuAssignDeviceShmemAlias-and-use-it.patch +++ /dev/null @@ -1,85 +0,0 @@ -From 27452e33f75a6bc6562d6a6992b496e9e0e25f93 Mon Sep 17 00:00:00 2001 -Message-Id: <27452e33f75a6bc6562d6a6992b496e9e0e25f93@dist-git> -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:43 +0100 -Subject: [PATCH] qemu: Add qemuAssignDeviceShmemAlias and use it - -Signed-off-by: Martin Kletzander -(cherry picked from commit a9996a45992d6d204ec922d836b26da65e3f7191) - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/qemu/qemu_alias.c | 32 +++++++++++++++++++++++++++++++- - src/qemu/qemu_alias.h | 4 ++++ - 2 files changed, 35 insertions(+), 1 deletion(-) - -diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c -index a85d3d1..9d4b1d6 100644 ---- a/src/qemu/qemu_alias.c -+++ b/src/qemu/qemu_alias.c -@@ -351,6 +351,36 @@ qemuAssignDeviceMemoryAlias(virDomainDefPtr def, - - - int -+qemuAssignDeviceShmemAlias(virDomainDefPtr def, -+ virDomainShmemDefPtr shmem, -+ int idx) -+{ -+ if (idx == -1) { -+ size_t i; -+ idx = 0; -+ for (i = 0; i < def->nshmems; i++) { -+ int thisidx; -+ -+ if ((thisidx = qemuDomainDeviceAliasIndex(&def->shmems[i]->info, -+ "shmem")) < 0) { -+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", -+ _("Unable to determine device index " -+ "for shmem device")); -+ return -1; -+ } -+ -+ if (thisidx >= idx) -+ idx = thisidx + 1; -+ } -+ } -+ -+ if (virAsprintf(&shmem->info.alias, "shmem%d", idx) < 0) -+ return -1; -+ return 0; -+} -+ -+ -+int - qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) - { - size_t i; -@@ -419,7 +449,7 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) - return -1; - } - for (i = 0; i < def->nshmems; i++) { -- if (virAsprintf(&def->shmems[i]->info.alias, "shmem%zu", i) < 0) -+ if (qemuAssignDeviceShmemAlias(def, def->shmems[i], i) < 0) - return -1; - } - for (i = 0; i < def->nsmartcards; i++) { -diff --git a/src/qemu/qemu_alias.h b/src/qemu/qemu_alias.h -index bb19710..6aee457 100644 ---- a/src/qemu/qemu_alias.h -+++ b/src/qemu/qemu_alias.h -@@ -60,6 +60,10 @@ int qemuAssignDeviceRNGAlias(virDomainDefPtr def, - int qemuAssignDeviceMemoryAlias(virDomainDefPtr def, - virDomainMemoryDefPtr mems); - -+int qemuAssignDeviceShmemAlias(virDomainDefPtr def, -+ virDomainShmemDefPtr shmem, -+ int idx); -+ - int qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps); - - int qemuDomainDeviceAliasIndex(const virDomainDeviceInfo *info, --- -2.10.2 - diff --git a/SOURCES/libvirt-qemu-Add-qemuDomainCheckABIStability.patch b/SOURCES/libvirt-qemu-Add-qemuDomainCheckABIStability.patch new file mode 100644 index 0000000..581dc7c --- /dev/null +++ b/SOURCES/libvirt-qemu-Add-qemuDomainCheckABIStability.patch @@ -0,0 +1,110 @@ +From bf20b6cf07e5462c892b5e3c3d76a3c354606ea4 Mon Sep 17 00:00:00 2001 +Message-Id: +From: Jiri Denemark +Date: Wed, 14 Jun 2017 13:43:37 +0200 +Subject: [PATCH] qemu: Add qemuDomainCheckABIStability + +When making ABI stability checks for an active domain, we need to make +sure we use the same migratable definition which virDomainGetXMLDesc +with the MIGRATABLE flag provides, otherwise the ABI check will fail. +This is implemented in the new qemuDomainCheckABIStability which takes a +domain object and generates the right migratable definition from it. + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit 063b2b8788db204d0ac2e1d367fd0c5eb9b81451) + +https://bugzilla.redhat.com/show_bug.cgi?id=1460952 + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_domain.c | 41 ++++++++++++++++++++++++++++++++++++----- + src/qemu/qemu_domain.h | 4 ++++ + 2 files changed, 40 insertions(+), 5 deletions(-) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index b3dc2bc3ac..1528c6a137 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -5909,6 +5909,10 @@ qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver, + } + + ++#define COPY_FLAGS (VIR_DOMAIN_XML_SECURE | \ ++ VIR_DOMAIN_XML_UPDATE_CPU | \ ++ VIR_DOMAIN_XML_MIGRATABLE) ++ + bool + qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + virDomainDefPtr src, +@@ -5916,13 +5920,10 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + { + virDomainDefPtr migratableDefSrc = NULL; + virDomainDefPtr migratableDefDst = NULL; +- const unsigned int flags = VIR_DOMAIN_XML_SECURE | +- VIR_DOMAIN_XML_UPDATE_CPU | +- VIR_DOMAIN_XML_MIGRATABLE; + bool ret = false; + +- if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) || +- !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags))) ++ if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, COPY_FLAGS)) || ++ !(migratableDefDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS))) + goto cleanup; + + ret = qemuDomainMigratableDefCheckABIStability(driver, +@@ -5935,6 +5936,36 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + return ret; + } + ++ ++bool ++qemuDomainCheckABIStability(virQEMUDriverPtr driver, ++ virDomainObjPtr vm, ++ virDomainDefPtr dst) ++{ ++ virDomainDefPtr migratableSrc = NULL; ++ virDomainDefPtr migratableDst = NULL; ++ char *xml = NULL; ++ bool ret = false; ++ ++ if (!(xml = qemuDomainFormatXML(driver, vm, COPY_FLAGS)) || ++ !(migratableSrc = qemuDomainDefFromXML(driver, xml)) || ++ !(migratableDst = qemuDomainDefCopy(driver, dst, COPY_FLAGS))) ++ goto cleanup; ++ ++ ret = qemuDomainMigratableDefCheckABIStability(driver, ++ vm->def, migratableSrc, ++ dst, migratableDst); ++ ++ cleanup: ++ VIR_FREE(xml); ++ virDomainDefFree(migratableSrc); ++ virDomainDefFree(migratableDst); ++ return ret; ++} ++ ++#undef COPY_FLAGS ++ ++ + bool + qemuDomainAgentAvailable(virDomainObjPtr vm, + bool reportError) +diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h +index d635d2995f..7ad34e563e 100644 +--- a/src/qemu/qemu_domain.h ++++ b/src/qemu/qemu_domain.h +@@ -668,6 +668,10 @@ bool qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + virDomainDefPtr src, + virDomainDefPtr dst); + ++bool qemuDomainCheckABIStability(virQEMUDriverPtr driver, ++ virDomainObjPtr vm, ++ virDomainDefPtr dst); ++ + bool qemuDomainAgentAvailable(virDomainObjPtr vm, + bool reportError); + +-- +2.13.1 + diff --git a/SOURCES/libvirt-qemu-Add-qemuDomainMigratableDefCheckABIStability.patch b/SOURCES/libvirt-qemu-Add-qemuDomainMigratableDefCheckABIStability.patch new file mode 100644 index 0000000..4bd3edf --- /dev/null +++ b/SOURCES/libvirt-qemu-Add-qemuDomainMigratableDefCheckABIStability.patch @@ -0,0 +1,82 @@ +From 2e728d3be5792685c38adbd61e80318e51985897 Mon Sep 17 00:00:00 2001 +Message-Id: <2e728d3be5792685c38adbd61e80318e51985897@dist-git> +From: Jiri Denemark +Date: Wed, 14 Jun 2017 13:43:12 +0200 +Subject: [PATCH] qemu: Add qemuDomainMigratableDefCheckABIStability + +This patch separates the actual ABI checks from getting migratable defs +in qemuDomainDefCheckABIStability so that we can create another wrapper +which will use different methods to get the migratable defs. + +Signed-off-by: Jiri Denemark +Reviewed-by: Pavel Hrdina +(cherry picked from commit a0912df3faac8b58725f45b8cf928990999585a3) + +https://bugzilla.redhat.com/show_bug.cgi?id=1460952 + +Signed-off-by: Jiri Denemark +--- + src/qemu/qemu_domain.c | 34 +++++++++++++++++++++++----------- + 1 file changed, 23 insertions(+), 11 deletions(-) + +diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c +index ce75105afa..b3dc2bc3ac 100644 +--- a/src/qemu/qemu_domain.c ++++ b/src/qemu/qemu_domain.c +@@ -5889,6 +5889,26 @@ virDomainABIStability virQEMUDriverDomainABIStability = { + }; + + ++static bool ++qemuDomainMigratableDefCheckABIStability(virQEMUDriverPtr driver, ++ virDomainDefPtr src, ++ virDomainDefPtr migratableSrc, ++ virDomainDefPtr dst, ++ virDomainDefPtr migratableDst) ++{ ++ if (!virDomainDefCheckABIStabilityFlags(migratableSrc, ++ migratableDst, ++ driver->xmlopt, ++ VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE)) ++ return false; ++ ++ /* Force update any skipped values from the volatile flag */ ++ dst->mem.cur_balloon = src->mem.cur_balloon; ++ ++ return true; ++} ++ ++ + bool + qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + virDomainDefPtr src, +@@ -5899,23 +5919,15 @@ qemuDomainDefCheckABIStability(virQEMUDriverPtr driver, + const unsigned int flags = VIR_DOMAIN_XML_SECURE | + VIR_DOMAIN_XML_UPDATE_CPU | + VIR_DOMAIN_XML_MIGRATABLE; +- const unsigned int check_flags = VIR_DOMAIN_DEF_ABI_CHECK_SKIP_VOLATILE; + bool ret = false; + + if (!(migratableDefSrc = qemuDomainDefCopy(driver, src, flags)) || + !(migratableDefDst = qemuDomainDefCopy(driver, dst, flags))) + goto cleanup; + +- if (!virDomainDefCheckABIStabilityFlags(migratableDefSrc, +- migratableDefDst, +- driver->xmlopt, +- check_flags)) +- goto cleanup; +- +- /* Force update any skipped values from the volatile flag */ +- dst->mem.cur_balloon = src->mem.cur_balloon; +- +- ret = true; ++ ret = qemuDomainMigratableDefCheckABIStability(driver, ++ src, migratableDefSrc, ++ dst, migratableDefDst); + + cleanup: + virDomainDefFree(migratableDefSrc); +-- +2.13.1 + diff --git a/SOURCES/libvirt-qemu-Add-qemuProcessSetupPid-and-use-it-in-qemuProcessSetupIOThread.patch b/SOURCES/libvirt-qemu-Add-qemuProcessSetupPid-and-use-it-in-qemuProcessSetupIOThread.patch deleted file mode 100644 index 49216d0..0000000 --- a/SOURCES/libvirt-qemu-Add-qemuProcessSetupPid-and-use-it-in-qemuProcessSetupIOThread.patch +++ /dev/null @@ -1,250 +0,0 @@ -From 341e7b3d6b2e1d1bc9c11aa59ebac376f847da87 Mon Sep 17 00:00:00 2001 -Message-Id: <341e7b3d6b2e1d1bc9c11aa59ebac376f847da87@dist-git> -From: Martin Kletzander -Date: Wed, 24 Aug 2016 16:10:54 -0400 -Subject: [PATCH] qemu: Add qemuProcessSetupPid() and use it in - qemuProcessSetupIOThread() - -https://bugzilla.redhat.com/show_bug.cgi?id=1097930 -https://bugzilla.redhat.com/show_bug.cgi?id=1224341 - -Setting up cgroups and other things for all kinds of threads (the -emulator thread, vCPU threads, I/O threads) was copy-pasted every time -new thing was added. Over time each one of those functions changed a -bit differently. So create one function that does all that setup and -start using it, starting with I/O thread setup. That will shave some -duplicated code and maybe fix some bugs as well. - -Signed-off-by: Martin Kletzander -(cherry picked from commit 71e419bbeb7d7bf6f9be0c2516c320cfb7492ef3) ---- - src/qemu/qemu_process.c | 200 +++++++++++++++++++++++++++--------------------- - 1 file changed, 114 insertions(+), 86 deletions(-) - -diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c -index 41e401b..64b1ac9 100644 ---- a/src/qemu/qemu_process.c -+++ b/src/qemu/qemu_process.c -@@ -2304,6 +2304,114 @@ qemuProcessSetLinkStates(virQEMUDriverPtr driver, - } - - -+/** -+ * qemuProcessSetupPid: -+ * -+ * This function sets resource properities (affinity, cgroups, -+ * scheduler) for any PID associated with a domain. It should be used -+ * to set up emulator PIDs as well as vCPU and I/O thread pids to -+ * ensure they are all handled the same way. -+ * -+ * Returns 0 on success, -1 on error. -+ */ -+static int -+qemuProcessSetupPid(virDomainObjPtr vm, -+ pid_t pid, -+ virCgroupThreadName nameval, -+ int id, -+ virBitmapPtr cpumask, -+ unsigned long long period, -+ long long quota, -+ virDomainThreadSchedParamPtr sched) -+{ -+ qemuDomainObjPrivatePtr priv = vm->privateData; -+ virDomainNumatuneMemMode mem_mode; -+ virCgroupPtr cgroup = NULL; -+ virBitmapPtr use_cpumask; -+ char *mem_mask = NULL; -+ int ret = -1; -+ -+ if ((period || quota) && -+ !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) { -+ virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -+ _("cgroup cpu is required for scheduler tuning")); -+ goto cleanup; -+ } -+ -+ /* Infer which cpumask shall be used. */ -+ if (cpumask) -+ use_cpumask = cpumask; -+ else if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) -+ use_cpumask = priv->autoCpuset; -+ else -+ use_cpumask = vm->def->cpumask; -+ -+ /* -+ * If CPU cgroup controller is not initialized here, then we need -+ * neither period nor quota settings. And if CPUSET controller is -+ * not initialized either, then there's nothing to do anyway. -+ */ -+ if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) || -+ virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { -+ -+ if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 && -+ mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && -+ virDomainNumatuneMaybeFormatNodeset(vm->def->numa, -+ priv->autoNodeset, -+ &mem_mask, -1) < 0) -+ goto cleanup; -+ -+ if (virCgroupNewThread(priv->cgroup, nameval, id, true, &cgroup) < 0) -+ goto cleanup; -+ -+ if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { -+ if (use_cpumask && -+ qemuSetupCgroupCpusetCpus(cgroup, use_cpumask) < 0) -+ goto cleanup; -+ -+ /* -+ * Don't setup cpuset.mems for the emulator, they need to -+ * be set up after initialization in order for kvm -+ * allocations to succeed. -+ */ -+ if (nameval != VIR_CGROUP_THREAD_EMULATOR && -+ mem_mask && virCgroupSetCpusetMems(cgroup, mem_mask) < 0) -+ goto cleanup; -+ -+ } -+ -+ if ((period || quota) && -+ qemuSetupCgroupVcpuBW(cgroup, period, quota) < 0) -+ goto cleanup; -+ -+ /* Move the thread to the sub dir */ -+ if (virCgroupAddTask(cgroup, pid) < 0) -+ goto cleanup; -+ -+ } -+ -+ /* Setup legacy affinity. */ -+ if (use_cpumask && virProcessSetAffinity(pid, use_cpumask) < 0) -+ goto cleanup; -+ -+ /* Set scheduler type and priority. */ -+ if (sched && -+ virProcessSetScheduler(pid, sched->policy, sched->priority) < 0) -+ goto cleanup; -+ -+ ret = 0; -+ cleanup: -+ VIR_FREE(mem_mask); -+ if (cgroup) { -+ if (ret < 0) -+ virCgroupRemove(cgroup); -+ virCgroupFree(&cgroup); -+ } -+ -+ return ret; -+} -+ -+ - static int - qemuProcessSetupEmulator(virDomainObjPtr vm) - { -@@ -4704,98 +4812,18 @@ qemuProcessSetupVcpus(virDomainObjPtr vm) - } - - --/** -- * qemuProcessSetupIOThread: -- * @vm: domain object -- * @iothread: iothread data structure to set the data for -- * -- * This function sets resource properities (affinity, cgroups, scheduler) for a -- * IOThread. This function expects that the IOThread is online and the IOThread -- * pids were correctly detected at the point when it's called. -- * -- * Returns 0 on success, -1 on error. -- */ - int - qemuProcessSetupIOThread(virDomainObjPtr vm, - virDomainIOThreadIDDefPtr iothread) - { -- qemuDomainObjPrivatePtr priv = vm->privateData; -- unsigned long long period = vm->def->cputune.period; -- long long quota = vm->def->cputune.quota; -- virDomainNumatuneMemMode mem_mode; -- char *mem_mask = NULL; -- virCgroupPtr cgroup_iothread = NULL; -- virBitmapPtr cpumask = NULL; -- int ret = -1; - -- if ((period || quota) && -- !virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU)) { -- virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", -- _("cgroup cpu is required for scheduler tuning")); -- return -1; -- } -- -- if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPU) || -- virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { -- if (virDomainNumatuneGetMode(vm->def->numa, -1, &mem_mode) == 0 && -- mem_mode == VIR_DOMAIN_NUMATUNE_MEM_STRICT && -- virDomainNumatuneMaybeFormatNodeset(vm->def->numa, -- priv->autoNodeset, -- &mem_mask, -1) < 0) -- goto cleanup; -- -- if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_IOTHREAD, -+ return qemuProcessSetupPid(vm, iothread->thread_id, -+ VIR_CGROUP_THREAD_IOTHREAD, - iothread->iothread_id, -- true, &cgroup_iothread) < 0) -- goto cleanup; -- } -- -- if (iothread->cpumask) -- cpumask = iothread->cpumask; -- else if (vm->def->placement_mode == VIR_DOMAIN_CPU_PLACEMENT_MODE_AUTO) -- cpumask = priv->autoCpuset; -- else -- cpumask = vm->def->cpumask; -- -- if (period || quota) { -- if (qemuSetupCgroupVcpuBW(cgroup_iothread, period, quota) < 0) -- goto cleanup; -- } -- -- if (cgroup_iothread) { -- if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_CPUSET)) { -- if (mem_mask && -- virCgroupSetCpusetMems(cgroup_iothread, mem_mask) < 0) -- goto cleanup; -- -- if (cpumask && -- qemuSetupCgroupCpusetCpus(cgroup_iothread, cpumask) < 0) -- goto cleanup; -- } -- -- if (virCgroupAddTask(cgroup_iothread, iothread->thread_id) < 0) -- goto cleanup; -- } -- -- if (cpumask && virProcessSetAffinity(iothread->thread_id, cpumask) < 0) -- goto cleanup; -- -- if (iothread->sched.policy != VIR_PROC_POLICY_NONE && -- virProcessSetScheduler(iothread->thread_id, iothread->sched.policy, -- iothread->sched.priority) < 0) -- goto cleanup; -- -- ret = 0; -- -- cleanup: -- if (cgroup_iothread) { -- if (ret < 0) -- virCgroupRemove(cgroup_iothread); -- virCgroupFree(&cgroup_iothread); -- } -- -- VIR_FREE(mem_mask); -- return ret; -+ iothread->cpumask, -+ vm->def->cputune.period, -+ vm->def->cputune.quota, -+ &iothread->sched); - } - - --- -2.10.0 - diff --git a/SOURCES/libvirt-qemu-Add-secinfo-for-hotplug-virtio-disk.patch b/SOURCES/libvirt-qemu-Add-secinfo-for-hotplug-virtio-disk.patch deleted file mode 100644 index 55fc915..0000000 --- a/SOURCES/libvirt-qemu-Add-secinfo-for-hotplug-virtio-disk.patch +++ /dev/null @@ -1,137 +0,0 @@ -From ff0dba475aad3bcad524391a7fddfede1e6fe189 Mon Sep 17 00:00:00 2001 -Message-Id: -From: John Ferlan -Date: Mon, 25 Jul 2016 12:42:58 -0400 -Subject: [PATCH] qemu: Add secinfo for hotplug virtio disk - -https://bugzilla.redhat.com/show_bug.cgi?id=1301021 - -Commit id 'a1344f70a' added AES secret processing for RBD when starting -up a guest. As such, when the hotplug code calls qemuDomainSecretDiskPrepare -an AES secret could be added to the disk about to be hotplugged. If an AES -secret was added, then the hotplug code would need to generate the secret -object because qemuBuildDriveStr would add the "password-secret=" to the -returned 'driveStr' rather than the base64 encoded password. - -Signed-off-by: John Ferlan -(cherry picked from commit fceeeda2115bcb86b992c4add38704a886c099c8) ---- - src/qemu/qemu_hotplug.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ - 1 file changed, 46 insertions(+) - -diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c -index b3fab6a..084443f 100644 ---- a/src/qemu/qemu_hotplug.c -+++ b/src/qemu/qemu_hotplug.c -@@ -303,6 +303,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - virDomainDiskDefPtr disk) - { - int ret = -1; -+ int rv; - qemuDomainObjPrivatePtr priv = vm->privateData; - virErrorPtr orig_err; - char *devstr = NULL; -@@ -310,8 +311,12 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - char *drivealias = NULL; - bool releaseaddr = false; - bool driveAdded = false; -+ bool secobjAdded = false; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - const char *src = virDomainDiskGetSource(disk); -+ virJSONValuePtr secobjProps = NULL; -+ qemuDomainDiskPrivatePtr diskPriv; -+ qemuDomainSecretInfoPtr secinfo; - - if (!disk->info.type) { - if (qemuDomainMachineIsS390CCW(vm->def) && -@@ -344,6 +349,13 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - if (qemuDomainSecretDiskPrepare(conn, priv, disk) < 0) - goto error; - -+ diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); -+ secinfo = diskPriv->secinfo; -+ if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) { -+ if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0) -+ goto error; -+ } -+ - if (!(drivestr = qemuBuildDriveStr(disk, false, priv->qemuCaps))) - goto error; - -@@ -358,6 +370,15 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - - qemuDomainObjEnterMonitor(driver, vm); - -+ if (secobjProps) { -+ rv = qemuMonitorAddObject(priv->mon, "secret", secinfo->s.aes.alias, -+ secobjProps); -+ secobjProps = NULL; /* qemuMonitorAddObject consumes */ -+ if (rv < 0) -+ goto exit_monitor; -+ } -+ secobjAdded = true; -+ - if (qemuMonitorAddDrive(priv->mon, drivestr) < 0) - goto exit_monitor; - driveAdded = true; -@@ -376,6 +397,7 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - ret = 0; - - cleanup: -+ virJSONValueFree(secobjProps); - qemuDomainSecretDiskDestroy(disk); - VIR_FREE(devstr); - VIR_FREE(drivestr); -@@ -389,10 +411,13 @@ qemuDomainAttachVirtioDiskDevice(virConnectPtr conn, - VIR_WARN("Unable to remove drive %s (%s) after failed " - "qemuMonitorAddDevice", drivealias, drivestr); - } -+ if (secobjAdded) -+ ignore_value(qemuMonitorDelObject(priv->mon, secinfo->s.aes.alias)); - if (orig_err) { - virSetError(orig_err); - virFreeError(orig_err); - } -+ - if (qemuDomainObjExitMonitor(driver, vm) < 0) - releaseaddr = false; - -@@ -2830,6 +2855,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, - const char *src = virDomainDiskGetSource(disk); - qemuDomainObjPrivatePtr priv = vm->privateData; - char *drivestr; -+ char *objAlias = NULL; - - VIR_DEBUG("Removing disk %s from domain %p %s", - disk->info.alias, vm, vm->def->name); -@@ -2840,7 +2866,27 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, - QEMU_DRIVE_HOST_PREFIX, disk->info.alias) < 0) - return -1; - -+ /* Let's look for some markers for a secret object and create an alias -+ * object to be used to attempt to delete the object that was created. -+ * We cannot just use the disk private secret info since it would have -+ * been removed during cleanup of qemuProcessLaunch. Likewise, libvirtd -+ * restart wouldn't have them, so no assumption can be made. */ -+ if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_OBJECT_SECRET) && -+ qemuDomainSecretDiskCapable(disk->src)) { -+ -+ if (!(objAlias = qemuDomainGetSecretAESAlias(disk->info.alias))) { -+ VIR_FREE(drivestr); -+ return -1; -+ } -+ } -+ - qemuDomainObjEnterMonitor(driver, vm); -+ -+ /* If it fails, then so be it - it was a best shot */ -+ if (objAlias) -+ ignore_value(qemuMonitorDelObject(priv->mon, objAlias)); -+ VIR_FREE(objAlias); -+ - qemuMonitorDriveDel(priv->mon, drivestr); - VIR_FREE(drivestr); - if (qemuDomainObjExitMonitor(driver, vm) < 0) --- -2.9.2 - diff --git a/SOURCES/libvirt-qemu-Add-support-for-guest-CPU-cache.patch b/SOURCES/libvirt-qemu-Add-support-for-guest-CPU-cache.patch index b641675..e9c0308 100644 --- a/SOURCES/libvirt-qemu-Add-support-for-guest-CPU-cache.patch +++ b/SOURCES/libvirt-qemu-Add-support-for-guest-CPU-cache.patch @@ -1,5 +1,5 @@ -From b638d9571e6497978c350e86671d9161c0b4c314 Mon Sep 17 00:00:00 2001 -Message-Id: +From b34dc87751a8667f22ea78730a5b678f5bd469a4 Mon Sep 17 00:00:00 2001 +Message-Id: From: Jiri Denemark Date: Tue, 25 Apr 2017 19:07:19 +0200 Subject: [PATCH] qemu: Add support for guest CPU cache @@ -40,37 +40,32 @@ doing so explicitly does not make any harm. Signed-off-by: Jiri Denemark (cherry picked from commit df13c0b477ffda460eed259c3b8aab7255f11199) -https://bugzilla.redhat.com/show_bug.cgi?id=1447612 - -Conflicts: - - mostly context onflicts - - qemuDomainDefCPUPostParse did not exist in 7.3 - - QEMU_CAPS_CPU_CACHE capability was not backported because it - depends on non-existent QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION and - thus it would never be set anyway; in other words, l3-cache=off - and host-cache-info=off will never be used +https://bugzilla.redhat.com/show_bug.cgi?id=1428952 Signed-off-by: Jiri Denemark --- - src/qemu/qemu_command.c | 23 ++++++++ - src/qemu/qemu_domain.c | 67 ++++++++++++++++++++++ - .../qemuxml2argv-cpu-cache-disable.args | 21 +++++++ - .../qemuxml2argv-cpu-cache-disable.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-disable2.args | 21 +++++++ - .../qemuxml2argv-cpu-cache-disable2.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-disable3.args | 22 +++++++ - .../qemuxml2argv-cpu-cache-disable3.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-emulate-l2.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-emulate-l3.args | 21 +++++++ - .../qemuxml2argv-cpu-cache-emulate-l3.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-passthrough-l3.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-passthrough.args | 21 +++++++ - .../qemuxml2argv-cpu-cache-passthrough.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-passthrough2.args | 21 +++++++ - .../qemuxml2argv-cpu-cache-passthrough2.xml | 20 +++++++ - .../qemuxml2argv-cpu-cache-passthrough3.xml | 20 +++++++ - tests/qemuxml2argvtest.c | 9 +++ - 18 files changed, 406 insertions(+) + src/qemu/qemu_capabilities.c | 5 ++ + src/qemu/qemu_capabilities.h | 1 + + src/qemu/qemu_command.c | 39 ++++++++++++++++ + src/qemu/qemu_domain.c | 54 ++++++++++++++++++++++ + tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml | 1 + + .../qemuxml2argv-cpu-cache-disable.args | 21 +++++++++ + .../qemuxml2argv-cpu-cache-disable.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-disable2.args | 21 +++++++++ + .../qemuxml2argv-cpu-cache-disable2.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-disable3.args | 22 +++++++++ + .../qemuxml2argv-cpu-cache-disable3.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-emulate-l2.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-emulate-l3.args | 21 +++++++++ + .../qemuxml2argv-cpu-cache-emulate-l3.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-passthrough-l3.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-passthrough.args | 21 +++++++++ + .../qemuxml2argv-cpu-cache-passthrough.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-passthrough2.args | 21 +++++++++ + .../qemuxml2argv-cpu-cache-passthrough2.xml | 20 ++++++++ + .../qemuxml2argv-cpu-cache-passthrough3.xml | 20 ++++++++ + tests/qemuxml2argvtest.c | 10 ++++ + 21 files changed, 417 insertions(+) create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable2.args @@ -87,16 +82,53 @@ Signed-off-by: Jiri Denemark create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough2.xml create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough3.xml +diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c +index 950a42bae..2c845853a 100644 +--- a/src/qemu/qemu_capabilities.c ++++ b/src/qemu/qemu_capabilities.c +@@ -364,6 +364,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST, + "query-cpu-definitions", /* 250 */ + "block-write-threshold", + "query-named-block-nodes", ++ "cpu-cache", + ); + + +@@ -4648,6 +4649,10 @@ virQEMUCapsInitQMPMonitor(virQEMUCapsPtr qemuCaps, + virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM)) + virQEMUCapsClear(qemuCaps, QEMU_CAPS_DEVICE_NVDIMM); + ++ if (ARCH_IS_X86(qemuCaps->arch) && ++ virQEMUCapsGet(qemuCaps, QEMU_CAPS_QUERY_CPU_MODEL_EXPANSION)) ++ virQEMUCapsSet(qemuCaps, QEMU_CAPS_CPU_CACHE); ++ + ret = 0; + cleanup: + return ret; +diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h +index 24e2f38ee..c466a63e7 100644 +--- a/src/qemu/qemu_capabilities.h ++++ b/src/qemu/qemu_capabilities.h +@@ -401,6 +401,7 @@ typedef enum { + QEMU_CAPS_QUERY_CPU_DEFINITIONS, /* qmp query-cpu-definitions */ + QEMU_CAPS_BLOCK_WRITE_THRESHOLD, /* BLOCK_WRITE_THRESHOLD event */ + QEMU_CAPS_QUERY_NAMED_BLOCK_NODES, /* qmp query-named-block-nodes */ ++ QEMU_CAPS_CPU_CACHE, /* -cpu supports host-cache-info and l3-cache properties */ + + QEMU_CAPS_LAST /* this must always be the last item */ + } virQEMUCapsFlags; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index bd01a0f76..f5b41257c 100644 +index ff7f47e06..2105cde58 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c -@@ -6854,6 +6854,29 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, +@@ -7071,6 +7071,45 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, have_cpu = true; } + if (def->cpu && def->cpu->cache) { + virCPUCacheDefPtr cache = def->cpu->cache; ++ bool hostOff = false; ++ bool l3Off = false; + + if (!have_cpu) { + virBufferAdd(&buf, default_model, -1); @@ -106,34 +138,43 @@ index bd01a0f76..f5b41257c 100644 + switch (cache->mode) { + case VIR_CPU_CACHE_MODE_EMULATE: + virBufferAddLit(&buf, ",l3-cache=on"); ++ hostOff = true; + break; + + case VIR_CPU_CACHE_MODE_PASSTHROUGH: + virBufferAddLit(&buf, ",host-cache-info=on"); ++ l3Off = true; + break; + + case VIR_CPU_CACHE_MODE_DISABLE: ++ hostOff = l3Off = true; ++ break; ++ + case VIR_CPU_CACHE_MODE_LAST: + break; + } ++ ++ if (hostOff && ++ def->cpu->mode == VIR_CPU_MODE_HOST_PASSTHROUGH && ++ virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_CACHE)) ++ virBufferAddLit(&buf, ",host-cache-info=off"); ++ ++ if (l3Off && ++ virQEMUCapsGet(qemuCaps, QEMU_CAPS_CPU_CACHE)) ++ virBufferAddLit(&buf, ",l3-cache=off"); + } + if (virBufferCheckError(&buf) < 0) goto cleanup; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c -index b91db229f..7aa6de742 100644 +index 9c09ced0c..d31645fd1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c -@@ -2328,6 +2328,70 @@ qemuDomainDefVcpusPostParse(virDomainDefPtr def) - +@@ -2688,6 +2688,60 @@ qemuDomainDefCPUPostParse(virDomainDefPtr def) + if (!def->cpu) + return 0; - static int -+qemuDomainDefCPUPostParse(virDomainDefPtr def) -+{ -+ if (!def->cpu) -+ return 0; -+ + if (def->cpu->cache) { + virCPUCacheDefPtr cache = def->cpu->cache; + @@ -188,27 +229,24 @@ index b91db229f..7aa6de742 100644 + } + } + -+ return 0; -+} -+ -+ -+static int - qemuDomainDefPostParse(virDomainDefPtr def, - virCapsPtr caps, - unsigned int parseFlags, -@@ -2385,6 +2449,9 @@ qemuDomainDefPostParse(virDomainDefPtr def, - if (qemuDomainDefVcpusPostParse(def) < 0) - goto cleanup; - -+ if (qemuDomainDefCPUPostParse(def) < 0) -+ goto cleanup; -+ - ret = 0; - cleanup: - virObjectUnref(qemuCaps); + /* Nothing to be done if only CPU topology is specified. */ + if (def->cpu->mode == VIR_CPU_MODE_CUSTOM && + !def->cpu->model) +diff --git a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +index 6386c4ed0..496c9ceb8 100644 +--- a/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml ++++ b/tests/qemucapabilitiesdata/caps_2.9.0.x86_64.xml +@@ -207,6 +207,7 @@ + + + ++ + 2008090 + 0 + (v2.9.0-rc0-142-g940a8ce) diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args new file mode 100644 -index 000000000..9348e01f8 +index 000000000..386e38d37 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable.args @@ -0,0 +1,21 @@ @@ -222,7 +260,7 @@ index 000000000..9348e01f8 +-name foo \ +-S \ +-M pc \ -+-cpu host \ ++-cpu host,host-cache-info=off,l3-cache=off \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ @@ -314,7 +352,7 @@ index 000000000..e6f39951c + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args new file mode 100644 -index 000000000..bbfd5ba2c +index 000000000..b882710c1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-disable3.args @@ -0,0 +1,22 @@ @@ -329,7 +367,7 @@ index 000000000..bbfd5ba2c +-S \ +-M pc \ +-cpu core2duo,+ds,+acpi,+ss,+ht,+tm,+pbe,+ds_cpl,+vmx,+est,+tm2,+cx16,+xtpr,\ -++lahf_lm \ +++lahf_lm,l3-cache=off \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ @@ -368,7 +406,7 @@ index 000000000..17078a1e8 + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml new file mode 100644 -index 000000000..0d1652e5c +index 000000000..4757e85ea --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l2.xml @@ -0,0 +1,20 @@ @@ -382,7 +420,7 @@ index 000000000..0d1652e5c + hvm + + -+ ++ + + + @@ -394,7 +432,7 @@ index 000000000..0d1652e5c + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args new file mode 100644 -index 000000000..0b9fb18e9 +index 000000000..c2f5d19e1 --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-emulate-l3.args @@ -0,0 +1,21 @@ @@ -408,7 +446,7 @@ index 000000000..0b9fb18e9 +-name foo \ +-S \ +-M pc \ -+-cpu host,l3-cache=on \ ++-cpu host,l3-cache=on,host-cache-info=off \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ @@ -473,7 +511,7 @@ index 000000000..3471115ea + diff --git a/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args new file mode 100644 -index 000000000..d7863ba2e +index 000000000..1d824f6dd --- /dev/null +++ b/tests/qemuxml2argvdata/qemuxml2argv-cpu-cache-passthrough.args @@ -0,0 +1,21 @@ @@ -487,7 +525,7 @@ index 000000000..d7863ba2e +-name foo \ +-S \ +-M pc \ -+-cpu host,host-cache-info=on \ ++-cpu host,host-cache-info=on,l3-cache=off \ +-m 214 \ +-smp 1,sockets=1,cores=1,threads=1 \ +-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \ @@ -604,22 +642,23 @@ index 000000000..6ad65700b + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index cbf785e1b..3cc798782 100644 +index 94be771d3..81cd2a6ec 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c -@@ -2117,6 +2117,15 @@ mymain(void) - - DO_TEST("cpu-hotplug-startup", QEMU_CAPS_QUERY_HOTPLUGGABLE_CPUS); +@@ -2521,6 +2521,16 @@ mymain(void) + DO_TEST("cpu-check-default-partial", QEMU_CAPS_KVM); + DO_TEST("cpu-check-default-partial2", QEMU_CAPS_KVM); -+ DO_TEST("cpu-cache-disable", QEMU_CAPS_KVM); ++ DO_TEST("cpu-cache-disable", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE); + DO_TEST("cpu-cache-disable2", QEMU_CAPS_KVM); -+ DO_TEST("cpu-cache-disable3", QEMU_CAPS_KVM); -+ DO_TEST("cpu-cache-passthrough", QEMU_CAPS_KVM); ++ DO_TEST("cpu-cache-disable3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE); ++ DO_TEST("cpu-cache-passthrough", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE); + DO_TEST("cpu-cache-passthrough2", QEMU_CAPS_KVM); -+ DO_TEST("cpu-cache-emulate-l3", QEMU_CAPS_KVM); ++ DO_TEST("cpu-cache-emulate-l3", QEMU_CAPS_KVM, QEMU_CAPS_CPU_CACHE); + DO_TEST_PARSE_ERROR("cpu-cache-emulate-l2", QEMU_CAPS_KVM); + DO_TEST_PARSE_ERROR("cpu-cache-passthrough3", QEMU_CAPS_KVM); + DO_TEST_PARSE_ERROR("cpu-cache-passthrough-l3", QEMU_CAPS_KVM); ++ qemuTestDriverFree(&driver); return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/SOURCES/libvirt-qemu-Add-support-for-hot-cold-un-plug-of-shmem-devices.patch b/SOURCES/libvirt-qemu-Add-support-for-hot-cold-un-plug-of-shmem-devices.patch deleted file mode 100644 index 298324d..0000000 --- a/SOURCES/libvirt-qemu-Add-support-for-hot-cold-un-plug-of-shmem-devices.patch +++ /dev/null @@ -1,701 +0,0 @@ -From fa914e6aea49d5cdc063b366a793d4d76a3a4030 Mon Sep 17 00:00:00 2001 -Message-Id: -From: Martin Kletzander -Date: Fri, 4 Nov 2016 10:29:54 +0100 -Subject: [PATCH] qemu: Add support for hot/cold-(un)plug of shmem devices - -This is needed in order to migrate a domain with shmem devices as that -is not allowed to migrate. - -Signed-off-by: Martin Kletzander -(cherry picked from commit fb2d0cc6332ed2d5546aad623792231d619a4707) - - Conflicts: - tests/qemuhotplugtest.c -- ccw hotplug tests - tests/qemuhotplugtestdata -- directories refactor - -https://bugzilla.redhat.com/show_bug.cgi?id=1392031 - -Signed-off-by: Martin Kletzander ---- - src/qemu/qemu_driver.c | 39 +++- - src/qemu/qemu_hotplug.c | 239 ++++++++++++++++++++- - src/qemu/qemu_hotplug.h | 6 + - tests/qemuhotplugtest.c | 21 ++ - ...uhotplug-hotplug-base-live+ivshmem-doorbell.xml | 65 ++++++ - ...plug-hotplug-base-live+ivshmem-plain-detach.xml | 1 + - ...qemuhotplug-hotplug-base-live+ivshmem-plain.xml | 1 + - .../qemuhotplug-ivshmem-doorbell-detach.xml | 7 + - .../qemuhotplug-ivshmem-doorbell.xml | 4 + - .../qemuhotplug-ivshmem-plain-detach.xml | 6 + - .../qemuhotplug-ivshmem-plain.xml | 3 + - ...emuxml2argv-hotplug-base-live+ivshmem-plain.xml | 58 +++++ - 12 files changed, 445 insertions(+), 5 deletions(-) - create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-doorbell.xml - create mode 120000 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain-detach.xml - create mode 120000 tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain.xml - create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell-detach.xml - create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell.xml - create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain-detach.xml - create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain.xml - create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-hotplug-base-live+ivshmem-plain.xml - -diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index 6775327..9b4d54b 100644 ---- a/src/qemu/qemu_driver.c -+++ b/src/qemu/qemu_driver.c -@@ -7519,6 +7519,15 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, - dev->data.memory = NULL; - break; - -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ ret = qemuDomainAttachShmemDevice(driver, vm, -+ dev->data.shmem); -+ if (ret < 0) { -+ alias = dev->data.shmem->info.alias; -+ dev->data.shmem = NULL; -+ } -+ break; -+ - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_FS: - case VIR_DOMAIN_DEVICE_INPUT: -@@ -7530,7 +7539,6 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: -- case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_IOMMU: -@@ -7609,6 +7617,9 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, - case VIR_DOMAIN_DEVICE_MEMORY: - ret = qemuDomainDetachMemoryDevice(driver, vm, dev->data.memory); - break; -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ ret = qemuDomainDetachShmemDevice(driver, vm, dev->data.shmem); -+ break; - - case VIR_DOMAIN_DEVICE_FS: - case VIR_DOMAIN_DEVICE_INPUT: -@@ -7620,7 +7631,6 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: -- case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_REDIRDEV: - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: -@@ -7767,6 +7777,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - virDomainControllerDefPtr controller; - virDomainFSDefPtr fs; - virDomainRedirdevDefPtr redirdev; -+ virDomainShmemDefPtr shmem; - - switch ((virDomainDeviceType) dev->type) { - case VIR_DOMAIN_DEVICE_DISK: -@@ -7891,6 +7902,18 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - dev->data.redirdev = NULL; - break; - -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ shmem = dev->data.shmem; -+ if (virDomainShmemDefFind(vmdef, shmem) >= 0) { -+ virReportError(VIR_ERR_OPERATION_INVALID, "%s", -+ _("device is already in the domain configuration")); -+ return -1; -+ } -+ if (virDomainShmemDefInsert(vmdef, shmem) < 0) -+ return -1; -+ dev->data.shmem = NULL; -+ break; -+ - case VIR_DOMAIN_DEVICE_INPUT: - case VIR_DOMAIN_DEVICE_SOUND: - case VIR_DOMAIN_DEVICE_VIDEO: -@@ -7900,7 +7923,6 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: -- case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -@@ -8047,6 +8069,16 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, - virDomainRedirdevDefFree(virDomainRedirdevDefRemove(vmdef, idx)); - break; - -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ if ((idx = virDomainShmemDefFind(vmdef, dev->data.shmem)) < 0) { -+ virReportError(VIR_ERR_OPERATION_FAILED, "%s", -+ _("matching shmem device was not found")); -+ return -1; -+ } -+ -+ virDomainShmemDefFree(virDomainShmemDefRemove(vmdef, idx)); -+ break; -+ - - case VIR_DOMAIN_DEVICE_INPUT: - case VIR_DOMAIN_DEVICE_SOUND: -@@ -8057,7 +8089,6 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: -- case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: -diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c -index f038be5..df3764f 100644 ---- a/src/qemu/qemu_hotplug.c -+++ b/src/qemu/qemu_hotplug.c -@@ -2134,6 +2134,131 @@ qemuDomainAttachHostDevice(virConnectPtr conn, - return -1; - } - -+ -+int -+qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, -+ virDomainObjPtr vm, -+ virDomainShmemDefPtr shmem) -+{ -+ int ret = -1; -+ char *shmstr = NULL; -+ char *charAlias = NULL; -+ char *memAlias = NULL; -+ bool release_backing = false; -+ bool release_address = true; -+ virErrorPtr orig_err = NULL; -+ virJSONValuePtr props = NULL; -+ qemuDomainObjPrivatePtr priv = vm->privateData; -+ -+ switch ((virDomainShmemModel)shmem->model) { -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: -+ break; -+ -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: -+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, -+ _("live attach of shmem model '%s' is not supported"), -+ virDomainShmemModelTypeToString(shmem->model)); -+ /* fall-through */ -+ case VIR_DOMAIN_SHMEM_MODEL_LAST: -+ return -1; -+ } -+ -+ if (qemuAssignDeviceShmemAlias(vm->def, shmem, -1) < 0) -+ return -1; -+ -+ if (qemuDomainPrepareShmemChardev(shmem) < 0) -+ return -1; -+ -+ if (VIR_REALLOC_N(vm->def->shmems, vm->def->nshmems + 1) < 0) -+ return -1; -+ -+ if ((shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE || -+ shmem->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) && -+ (virDomainPCIAddressEnsureAddr(priv->pciaddrs, &shmem->info) < 0)) -+ return -1; -+ -+ if (!(shmstr = qemuBuildShmemDevStr(vm->def, shmem, priv->qemuCaps))) -+ goto cleanup; -+ -+ if (shmem->server.enabled) { -+ if (virAsprintf(&charAlias, "char%s", shmem->info.alias) < 0) -+ goto cleanup; -+ } else { -+ if (!(props = qemuBuildShmemBackendMemProps(shmem))) -+ goto cleanup; -+ -+ if (virAsprintf(&memAlias, "shmmem-%s", shmem->info.alias) < 0) -+ goto cleanup; -+ } -+ -+ qemuDomainObjEnterMonitor(driver, vm); -+ -+ if (shmem->server.enabled) { -+ if (qemuMonitorAttachCharDev(priv->mon, charAlias, -+ &shmem->server.chr) < 0) -+ goto exit_monitor; -+ } else { -+ if (qemuMonitorAddObject(priv->mon, "memory-backend-file", -+ memAlias, props) < 0) { -+ props = NULL; -+ goto exit_monitor; -+ } -+ props = NULL; -+ } -+ -+ release_backing = true; -+ -+ if (qemuMonitorAddDevice(priv->mon, shmstr) < 0) -+ goto exit_monitor; -+ -+ if (qemuDomainObjExitMonitor(driver, vm) < 0) { -+ release_address = false; -+ goto cleanup; -+ } -+ -+ /* Doing a copy here just so the pointer doesn't get nullified -+ * because we need it in the audit function */ -+ VIR_APPEND_ELEMENT_COPY_INPLACE(vm->def->shmems, vm->def->nshmems, shmem); -+ -+ ret = 0; -+ release_address = false; -+ -+ audit: -+ virDomainAuditShmem(vm, shmem, "attach", ret == 0); -+ -+ cleanup: -+ if (release_address) -+ qemuDomainReleaseDeviceAddress(vm, &shmem->info, NULL); -+ -+ virJSONValueFree(props); -+ VIR_FREE(memAlias); -+ VIR_FREE(charAlias); -+ VIR_FREE(shmstr); -+ -+ return ret; -+ -+ exit_monitor: -+ orig_err = virSaveLastError(); -+ if (release_backing) { -+ if (shmem->server.enabled) -+ ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias)); -+ else -+ ignore_value(qemuMonitorDelObject(priv->mon, memAlias)); -+ } -+ -+ if (orig_err) { -+ virSetError(orig_err); -+ virFreeError(orig_err); -+ } -+ -+ if (qemuDomainObjExitMonitor(driver, vm) < 0) -+ release_address = false; -+ -+ goto audit; -+} -+ -+ - static int - qemuDomainChangeNetBridge(virDomainObjPtr vm, - virDomainNetDefPtr olddev, -@@ -3398,6 +3523,62 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver, - } - - -+static int -+qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver, -+ virDomainObjPtr vm, -+ virDomainShmemDefPtr shmem) -+{ -+ int rc; -+ int ret = -1; -+ ssize_t idx = -1; -+ char *charAlias = NULL; -+ char *memAlias = NULL; -+ qemuDomainObjPrivatePtr priv = vm->privateData; -+ virObjectEventPtr event = NULL; -+ -+ VIR_DEBUG("Removing shmem device %s from domain %p %s", -+ shmem->info.alias, vm, vm->def->name); -+ -+ if (shmem->server.enabled) { -+ if (virAsprintf(&charAlias, "char%s", shmem->info.alias) < 0) -+ return -1; -+ } else { -+ if (virAsprintf(&memAlias, "shmmem-%s", shmem->info.alias) < 0) -+ return -1; -+ } -+ -+ qemuDomainObjEnterMonitor(driver, vm); -+ -+ if (shmem->server.enabled) -+ rc = qemuMonitorDetachCharDev(priv->mon, charAlias); -+ else -+ rc = qemuMonitorDelObject(priv->mon, memAlias); -+ -+ if (qemuDomainObjExitMonitor(driver, vm) < 0) -+ goto cleanup; -+ -+ virDomainAuditShmem(vm, shmem, "detach", rc == 0); -+ -+ if (rc < 0) -+ goto cleanup; -+ -+ event = virDomainEventDeviceRemovedNewFromObj(vm, shmem->info.alias); -+ qemuDomainEventQueue(driver, event); -+ -+ if ((idx = virDomainShmemDefFind(vm->def, shmem)) >= 0) -+ virDomainShmemDefRemove(vm->def, idx); -+ qemuDomainReleaseDeviceAddress(vm, &shmem->info, NULL); -+ virDomainShmemDefFree(shmem); -+ -+ ret = 0; -+ cleanup: -+ VIR_FREE(charAlias); -+ VIR_FREE(memAlias); -+ -+ return ret; -+} -+ -+ - int - qemuDomainRemoveDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, -@@ -3429,6 +3610,10 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, - ret = qemuDomainRemoveMemoryDevice(driver, vm, dev->data.memory); - break; - -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ ret = qemuDomainRemoveShmemDevice(driver, vm, dev->data.shmem); -+ break; -+ - case VIR_DOMAIN_DEVICE_NONE: - case VIR_DOMAIN_DEVICE_LEASE: - case VIR_DOMAIN_DEVICE_FS: -@@ -3442,7 +3627,6 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, - case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_MEMBALLOON: - case VIR_DOMAIN_DEVICE_NVRAM: -- case VIR_DOMAIN_DEVICE_SHMEM: - case VIR_DOMAIN_DEVICE_TPM: - case VIR_DOMAIN_DEVICE_PANIC: - case VIR_DOMAIN_DEVICE_IOMMU: -@@ -4017,6 +4201,59 @@ int qemuDomainDetachHostDevice(virQEMUDriverPtr driver, - return qemuDomainDetachThisHostDevice(driver, vm, detach); - } - -+ -+int -+qemuDomainDetachShmemDevice(virQEMUDriverPtr driver, -+ virDomainObjPtr vm, -+ virDomainShmemDefPtr dev) -+{ -+ int ret = -1; -+ ssize_t idx = -1; -+ virDomainShmemDefPtr shmem = NULL; -+ qemuDomainObjPrivatePtr priv = vm->privateData; -+ -+ if ((idx = virDomainShmemDefFind(vm->def, dev)) < 0) { -+ virReportError(VIR_ERR_OPERATION_INVALID, "%s", -+ _("device not present in domain configuration")); -+ return -1; -+ } -+ -+ shmem = vm->def->shmems[idx]; -+ -+ switch ((virDomainShmemModel)shmem->model) { -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_DOORBELL: -+ break; -+ -+ case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM: -+ virReportError(VIR_ERR_OPERATION_UNSUPPORTED, -+ _("live detach of shmem model '%s' is not supported"), -+ virDomainShmemModelTypeToString(shmem->model)); -+ /* fall-through */ -+ case VIR_DOMAIN_SHMEM_MODEL_LAST: -+ return -1; -+ } -+ -+ qemuDomainMarkDeviceForRemoval(vm, &shmem->info); -+ qemuDomainObjEnterMonitor(driver, vm); -+ -+ ret = qemuMonitorDelDevice(priv->mon, shmem->info.alias); -+ -+ if (qemuDomainObjExitMonitor(driver, vm) < 0) -+ ret = -1; -+ -+ if (ret == 0) { -+ if ((ret = qemuDomainWaitForDeviceRemoval(vm)) == 1) { -+ qemuDomainReleaseDeviceAddress(vm, &shmem->info, NULL); -+ ret = qemuDomainRemoveShmemDevice(driver, vm, shmem); -+ } -+ } -+ qemuDomainResetDeviceRemoval(vm); -+ -+ return ret; -+} -+ -+ - int - qemuDomainDetachNetDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, -diff --git a/src/qemu/qemu_hotplug.h b/src/qemu/qemu_hotplug.h -index b048cf4..ca54bbd 100644 ---- a/src/qemu/qemu_hotplug.h -+++ b/src/qemu/qemu_hotplug.h -@@ -50,6 +50,9 @@ int qemuDomainAttachHostDevice(virConnectPtr conn, - virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainHostdevDefPtr hostdev); -+int qemuDomainAttachShmemDevice(virQEMUDriverPtr driver, -+ virDomainObjPtr vm, -+ virDomainShmemDefPtr shmem); - int qemuDomainFindGraphicsIndex(virDomainDefPtr def, - virDomainGraphicsDefPtr dev); - int qemuDomainAttachMemory(virQEMUDriverPtr driver, -@@ -86,6 +89,9 @@ int qemuDomainDetachNetDevice(virQEMUDriverPtr driver, - int qemuDomainDetachHostDevice(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainDeviceDefPtr dev); -+int qemuDomainDetachShmemDevice(virQEMUDriverPtr driver, -+ virDomainObjPtr vm, -+ virDomainShmemDefPtr dev); - int qemuDomainAttachLease(virQEMUDriverPtr driver, - virDomainObjPtr vm, - virDomainLeaseDefPtr lease); -diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c -index 07b8091..9a92855 100644 ---- a/tests/qemuhotplugtest.c -+++ b/tests/qemuhotplugtest.c -@@ -73,6 +73,8 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, - - virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_VIRTIO_SCSI); - virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_USB_STORAGE); -+ virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_PLAIN); -+ virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_IVSHMEM_DOORBELL); - if (event) - virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); - -@@ -118,6 +120,9 @@ testQemuHotplugAttach(virDomainObjPtr vm, - case VIR_DOMAIN_DEVICE_CHR: - ret = qemuDomainAttachChrDevice(&driver, vm, dev->data.chr); - break; -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ ret = qemuDomainAttachShmemDevice(&driver, vm, dev->data.shmem); -+ break; - default: - VIR_TEST_VERBOSE("device type '%s' cannot be attached\n", - virDomainDeviceTypeToString(dev->type)); -@@ -140,6 +145,9 @@ testQemuHotplugDetach(virDomainObjPtr vm, - case VIR_DOMAIN_DEVICE_CHR: - ret = qemuDomainDetachChrDevice(&driver, vm, dev->data.chr); - break; -+ case VIR_DOMAIN_DEVICE_SHMEM: -+ ret = qemuDomainDetachShmemDevice(&driver, vm, dev->data.shmem); -+ break; - default: - VIR_TEST_VERBOSE("device type '%s' cannot be detached\n", - virDomainDeviceTypeToString(dev->type)); -@@ -602,6 +610,19 @@ mymain(void) - "device_del", QMP_OK, - "chardev-remove", QMP_OK); - -+ DO_TEST_ATTACH("hotplug-base-live", "ivshmem-plain", false, true, -+ "object-add", QMP_OK, -+ "device_add", QMP_OK); -+ DO_TEST_ATTACH("hotplug-base-live", "ivshmem-doorbell", false, true, -+ "chardev-add", QMP_OK, -+ "device_add", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live+ivshmem-plain", "ivshmem-doorbell-detach", false, true, -+ "device_del", QMP_OK, -+ "chardev-remove", QMP_OK); -+ DO_TEST_DETACH("hotplug-base-live", "ivshmem-plain-detach", false, false, -+ "device_del", QMP_OK, -+ "object-del", QMP_OK); -+ - qemuTestDriverFree(&driver); - return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE; - } -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-doorbell.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-doorbell.xml -new file mode 100644 -index 0000000..8d09fee ---- /dev/null -+++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-doorbell.xml -@@ -0,0 +1,65 @@ -+ -+ hotplug -+ d091ea82-29e6-2e34-3005-f02617b36e87 -+ 4194304 -+ 4194304 -+ 4 -+ -+ hvm -+ -+ -+ -+ -+ -+ -+ -+ -+ destroy -+ restart -+ restart -+ -+ /usr/libexec/qemu-kvm -+ -+ -+
      -+ -+ -+ -+
      -+ -+ -+ -+
      -+ -+ -+ -+ -+ -+ -+
      -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ 4 -+ -+
      -+ -+ -+ -+ -+ -+ -+
      -+ -+ -+ -+ -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain-detach.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain-detach.xml -new file mode 120000 -index 0000000..d5e2051 ---- /dev/null -+++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain-detach.xml -@@ -0,0 +1 @@ -+../qemuxml2argvdata/qemuxml2argv-hotplug-base-live.xml -\ No newline at end of file -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain.xml b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain.xml -new file mode 120000 -index 0000000..cf27c10 ---- /dev/null -+++ b/tests/qemuhotplugtestdata/qemuhotplug-hotplug-base-live+ivshmem-plain.xml -@@ -0,0 +1 @@ -+../qemuxml2argvdata/qemuxml2argv-hotplug-base-live+ivshmem-plain.xml -\ No newline at end of file -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell-detach.xml b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell-detach.xml -new file mode 100644 -index 0000000..7c06696 ---- /dev/null -+++ b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell-detach.xml -@@ -0,0 +1,7 @@ -+ -+ -+ -+ -+ -+
      -+ -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell.xml b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell.xml -new file mode 100644 -index 0000000..06cb0c9 ---- /dev/null -+++ b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-doorbell.xml -@@ -0,0 +1,4 @@ -+ -+ -+ -+ -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain-detach.xml b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain-detach.xml -new file mode 100644 -index 0000000..68f592f ---- /dev/null -+++ b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain-detach.xml -@@ -0,0 +1,6 @@ -+ -+ -+ 4 -+ -+
      -+ -diff --git a/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain.xml b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain.xml -new file mode 100644 -index 0000000..6bd96ff ---- /dev/null -+++ b/tests/qemuhotplugtestdata/qemuhotplug-ivshmem-plain.xml -@@ -0,0 +1,3 @@ -+ -+ -+ -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hotplug-base-live+ivshmem-plain.xml b/tests/qemuxml2argvdata/qemuxml2argv-hotplug-base-live+ivshmem-plain.xml -new file mode 100644 -index 0000000..ac3fa4f ---- /dev/null -+++ b/tests/qemuxml2argvdata/qemuxml2argv-hotplug-base-live+ivshmem-plain.xml -@@ -0,0 +1,58 @@ -+ -+ hotplug -+ d091ea82-29e6-2e34-3005-f02617b36e87 -+ 4194304 -+ 4194304 -+ 4 -+ -+ hvm -+ -+ -+ -+ -+ -+ -+ -+ -+ destroy -+ restart -+ restart -+ -+ /usr/libexec/qemu-kvm -+ -+ -+
      -+ -+ -+ -+
      -+ -+ -+ -+
      -+ -+ -+ -+ -+ -+ -+
      -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ 4 -+ -+
      -+ -+ -+ -+ --- -2.10.2 - diff --git a/SOURCES/libvirt-qemu-Add-support-for-using-AES-secret-for-SCSI-hotplug.patch b/SOURCES/libvirt-qemu-Add-support-for-using-AES-secret-for-SCSI-hotplug.patch deleted file mode 100644 index b657770..0000000 --- a/SOURCES/libvirt-qemu-Add-support-for-using-AES-secret-for-SCSI-hotplug.patch +++ /dev/null @@ -1,168 +0,0 @@ -From d003f242c8dd06903146604442e633fc286f88ba Mon Sep 17 00:00:00 2001 -Message-Id: -From: Gema Gomez -Date: Wed, 21 Dec 2016 15:55:41 -0500 -Subject: [PATCH] qemu: Add support for using AES secret for SCSI hotplug - -https://bugzilla.redhat.com/show_bug.cgi?id=1406442 - -Support for virtio disks was added in commit id 'fceeeda', but not for -SCSI drives. Add the secret for the server when hotplugging a SCSI drive. -No need to make any adjustments for unplug since that's handled during -the qemuDomainDetachDiskDevice call to qemuDomainRemoveDiskDevice in -the qemuDomainDetachDeviceDiskLive switch. - -Added a test to/for the command line processing to show the command line -options when adding a SCSI drive for the guest. - -(cherry picked from commit 0701abcb3ba78ba27cf1f47e01b3d9607ad37b72) - -Resolved conflict since upstream commit id '97ca6eed9a' is not present -(just remove the drivealias changes) - -https://bugzilla.redhat.com/show_bug.cgi?id=1411398 - -Signed-off-by: John Ferlan ---- - src/qemu/qemu_hotplug.c | 21 +++++++++++++++++++++ - ...emuxml2argv-disk-drive-network-rbd-auth-AES.args | 14 ++++++++++++-- - ...qemuxml2argv-disk-drive-network-rbd-auth-AES.xml | 13 +++++++++++++ - tests/qemuxml2argvtest.c | 2 +- - 4 files changed, 47 insertions(+), 3 deletions(-) - -diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c -index 58d25ca0e..967c7c0b7 100644 ---- a/src/qemu/qemu_hotplug.c -+++ b/src/qemu/qemu_hotplug.c -@@ -594,12 +594,15 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - char *devstr = NULL; - bool driveAdded = false; - bool encobjAdded = false; -+ bool secobjAdded = false; - int ret = -1; - int rv; - virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); - virJSONValuePtr encobjProps = NULL; -+ virJSONValuePtr secobjProps = NULL; - qemuDomainDiskPrivatePtr diskPriv; - qemuDomainSecretInfoPtr encinfo; -+ qemuDomainSecretInfoPtr secinfo; - - if (qemuDomainPrepareDisk(driver, vm, disk, NULL, false) < 0) - goto cleanup; -@@ -631,6 +634,12 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - goto error; - - diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk); -+ secinfo = diskPriv->secinfo; -+ if (secinfo && secinfo->type == VIR_DOMAIN_SECRET_INFO_TYPE_AES) { -+ if (qemuBuildSecretInfoProps(secinfo, &secobjProps) < 0) -+ goto error; -+ } -+ - encinfo = diskPriv->encinfo; - if (encinfo && qemuBuildSecretInfoProps(encinfo, &encobjProps) < 0) - goto error; -@@ -646,6 +655,15 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - - qemuDomainObjEnterMonitor(driver, vm); - -+ if (secobjProps) { -+ rv = qemuMonitorAddObject(priv->mon, "secret", secinfo->s.aes.alias, -+ secobjProps); -+ secobjProps = NULL; /* qemuMonitorAddObject consumes */ -+ if (rv < 0) -+ goto exit_monitor; -+ secobjAdded = true; -+ } -+ - if (encobjProps) { - rv = qemuMonitorAddObject(priv->mon, "secret", encinfo->s.aes.alias, - encobjProps); -@@ -671,6 +689,7 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - ret = 0; - - cleanup: -+ virJSONValueFree(secobjProps); - virJSONValueFree(encobjProps); - qemuDomainSecretDiskDestroy(disk); - VIR_FREE(devstr); -@@ -684,6 +703,8 @@ qemuDomainAttachSCSIDisk(virConnectPtr conn, - VIR_WARN("qemuMonitorAddDevice failed on %s (%s)", drivestr, devstr); - - orig_err = virSaveLastError(); -+ if (secobjAdded) -+ ignore_value(qemuMonitorDelObject(priv->mon, secinfo->s.aes.alias)); - if (encobjAdded) - ignore_value(qemuMonitorDelObject(priv->mon, encinfo->s.aes.alias)); - if (orig_err) { -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args -index dd66388f8..57b3d88a7 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args -+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.args -@@ -18,6 +18,7 @@ file=/tmp/lib/domain--1-QEMUGuest1/master-key.aes \ - -monitor unix:/tmp/lib/domain--1-QEMUGuest1/monitor.sock,server,nowait \ - -no-acpi \ - -boot c \ -+-device virtio-scsi-pci,id=scsi0,bus=pci.0,addr=0x3 \ - -usb \ - -drive file=/dev/HostVG/QEMUGuest1,format=raw,if=none,id=drive-ide0-0-0 \ - -device ide-drive,bus=ide.0,unit=0,drive=drive-ide0-0-0,id=ide0-0-0 \ -@@ -28,5 +29,14 @@ keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ - mon_host=mon1.example.org\:6321\;mon2.example.org\:6322\;mon3.example.org\:6322,\ - file.password-secret=virtio-disk0-secret0,format=raw,if=none,\ - id=drive-virtio-disk0' \ ---device virtio-blk-pci,bus=pci.0,addr=0x3,drive=drive-virtio-disk0,\ --id=virtio-disk0 -+-device virtio-blk-pci,bus=pci.0,addr=0x4,drive=drive-virtio-disk0,\ -+id=virtio-disk0 \ -+-object secret,id=scsi0-0-0-0-secret0,\ -+data=9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1,\ -+keyid=masterKey0,iv=AAECAwQFBgcICQoLDA0ODw==,format=base64 \ -+-drive 'file=rbd:pool/image:id=myname:auth_supported=cephx\;none:\ -+mon_host=mon1.example.org\:6321\;mon2.example.org\:6322\;mon3.example.org\:\ -+6322,file.password-secret=scsi0-0-0-0-secret0,format=raw,if=none,\ -+id=drive-scsi0-0-0-0,cache=none' \ -+-device scsi-disk,bus=scsi0.0,channel=0,scsi-id=0,lun=0,\ -+drive=drive-scsi0-0-0-0,id=scsi0-0-0-0 -diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.xml b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.xml -index ac2e94209..885fb1127 100644 ---- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.xml -+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-network-rbd-auth-AES.xml -@@ -32,7 +32,20 @@ - - - -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ -+ - -+ - - - -diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c -index f48632b70..dc5580e02 100644 ---- a/tests/qemuxml2argvtest.c -+++ b/tests/qemuxml2argvtest.c -@@ -827,7 +827,7 @@ mymain(void) - DO_TEST("disk-drive-network-rbd-auth", NONE); - # ifdef HAVE_GNUTLS_CIPHER_ENCRYPT - DO_TEST("disk-drive-network-rbd-auth-AES", -- QEMU_CAPS_OBJECT_SECRET); -+ QEMU_CAPS_OBJECT_SECRET, QEMU_CAPS_VIRTIO_SCSI); - # endif - DO_TEST("disk-drive-network-rbd-ipv6", NONE); - DO_TEST_FAILURE("disk-drive-network-rbd-no-colon", NONE); --- -2.11.1 - diff --git a/SOURCES/libvirt-qemu-Add-support-to-get-set-IOThread-period-and-quota-cgroup-values.patch b/SOURCES/libvirt-qemu-Add-support-to-get-set-IOThread-period-and-quota-cgroup-values.patch deleted file mode 100644 index ceca397..0000000 --- a/SOURCES/libvirt-qemu-Add-support-to-get-set-IOThread-period-and-quota-cgroup-values.patch +++ /dev/null @@ -1,241 +0,0 @@ -From 6a60677f21bd3ef90603e25d9c609c3f569918c3 Mon Sep 17 00:00:00 2001 -Message-Id: <6a60677f21bd3ef90603e25d9c609c3f569918c3@dist-git> -From: John Ferlan -Date: Tue, 6 Sep 2016 16:43:14 -0400 -Subject: [PATCH] qemu: Add support to get/set IOThread period and quota cgroup - values - -https://bugzilla.redhat.com/show_bug.cgi?id=1356937 - -Add support for IOThread quota/bandwidth and period parameters for non -session mode. If in session mode, then error out. Uses all the same -places where {vcpu|emulator|global}_{period|quota} are adjusted and -adds the iothread values. - -(cherry picked from commit e4e4d17c9c2828b3a7d2909295e724c57e60a334) -Signed-off-by: John Ferlan ---- - src/qemu/qemu_command.c | 3 +- - src/qemu/qemu_driver.c | 127 +++++++++++++++++++++++++++++++++++++++++++++++- - src/qemu/qemu_process.c | 4 +- - 3 files changed, 129 insertions(+), 5 deletions(-) - -diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c -index e292f48..de121c5 100644 ---- a/src/qemu/qemu_command.c -+++ b/src/qemu/qemu_command.c -@@ -9306,7 +9306,8 @@ qemuBuildCommandLineValidate(virQEMUDriverPtr driver, - if (def->cputune.sharesSpecified || def->cputune.period || - def->cputune.quota || def->cputune.global_period || - def->cputune.global_quota || def->cputune.emulator_period || -- def->cputune.emulator_quota) { -+ def->cputune.emulator_quota || def->cputune.iothread_period || -+ def->cputune.iothread_quota) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("CPU tuning is not available in session mode")); - return -1; -diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index 8081417..33bfb67 100644 ---- a/src/qemu/qemu_driver.c -+++ b/src/qemu/qemu_driver.c -@@ -8705,7 +8705,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom, - /* Domain not running, thus no cgroups - return defaults */ - if (!virDomainObjIsActive(vm)) { - if (nparams) -- *nparams = 7; -+ *nparams = 9; - ignore_value(VIR_STRDUP(ret, "posix")); - goto cleanup; - } -@@ -8718,7 +8718,7 @@ static char *qemuDomainGetSchedulerType(virDomainPtr dom, - - if (nparams) { - if (virCgroupSupportsCpuBW(priv->cgroup)) -- *nparams = 7; -+ *nparams = 9; - else - *nparams = 1; - } -@@ -9939,6 +9939,40 @@ qemuSetEmulatorBandwidthLive(virCgroupPtr cgroup, - return -1; - } - -+ -+static int -+qemuSetIOThreadsBWLive(virDomainObjPtr vm, virCgroupPtr cgroup, -+ unsigned long long period, long long quota) -+{ -+ size_t i; -+ virCgroupPtr cgroup_iothread = NULL; -+ -+ if (period == 0 && quota == 0) -+ return 0; -+ -+ if (!vm->def->niothreadids) -+ return 0; -+ -+ for (i = 0; i < vm->def->niothreadids; i++) { -+ if (virCgroupNewThread(cgroup, VIR_CGROUP_THREAD_IOTHREAD, -+ vm->def->iothreadids[i]->iothread_id, -+ false, &cgroup_iothread) < 0) -+ goto cleanup; -+ -+ if (qemuSetupCgroupVcpuBW(cgroup_iothread, period, quota) < 0) -+ goto cleanup; -+ -+ virCgroupFree(&cgroup_iothread); -+ } -+ -+ return 0; -+ -+ cleanup: -+ virCgroupFree(&cgroup_iothread); -+ return -1; -+} -+ -+ - #define SCHED_RANGE_CHECK(VAR, NAME, MIN, MAX) \ - if (((VAR) > 0 && (VAR) < (MIN)) || (VAR) > (MAX)) { \ - virReportError(VIR_ERR_INVALID_ARG, \ -@@ -9989,6 +10023,10 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom, - VIR_TYPED_PARAM_ULLONG, - VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA, - VIR_TYPED_PARAM_LLONG, -+ VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD, -+ VIR_TYPED_PARAM_ULLONG, -+ VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA, -+ VIR_TYPED_PARAM_LLONG, - NULL) < 0) - return -1; - -@@ -10181,6 +10219,46 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom, - - if (persistentDef) - persistentDefCopy->cputune.emulator_quota = value_l; -+ -+ } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD)) { -+ SCHED_RANGE_CHECK(value_ul, VIR_DOMAIN_SCHEDULER_IOTHREAD_PERIOD, -+ QEMU_SCHED_MIN_PERIOD, QEMU_SCHED_MAX_PERIOD); -+ -+ if (def && value_ul) { -+ if ((rc = qemuSetIOThreadsBWLive(vm, priv->cgroup, value_ul, 0))) -+ goto endjob; -+ -+ def->cputune.iothread_period = value_ul; -+ -+ if (virTypedParamsAddULLong(&eventParams, &eventNparams, -+ &eventMaxNparams, -+ VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_PERIOD, -+ value_ul) < 0) -+ goto endjob; -+ } -+ -+ if (persistentDef) -+ persistentDefCopy->cputune.iothread_period = params[i].value.ul; -+ -+ } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA)) { -+ SCHED_RANGE_CHECK(value_l, VIR_DOMAIN_SCHEDULER_IOTHREAD_QUOTA, -+ QEMU_SCHED_MIN_QUOTA, QEMU_SCHED_MAX_QUOTA); -+ -+ if (def && value_l) { -+ if ((rc = qemuSetIOThreadsBWLive(vm, priv->cgroup, 0, value_l))) -+ goto endjob; -+ -+ def->cputune.iothread_quota = value_l; -+ -+ if (virTypedParamsAddLLong(&eventParams, &eventNparams, -+ &eventMaxNparams, -+ VIR_DOMAIN_TUNABLE_CPU_IOTHREAD_QUOTA, -+ value_l) < 0) -+ goto endjob; -+ } -+ -+ if (persistentDef) -+ persistentDefCopy->cputune.iothread_quota = value_l; - } - } - -@@ -10304,6 +10382,43 @@ qemuGetEmulatorBandwidthLive(virCgroupPtr cgroup, - } - - static int -+qemuGetIOThreadsBWLive(virDomainObjPtr vm, -+ unsigned long long *period, long long *quota) -+{ -+ virCgroupPtr cgroup_iothread = NULL; -+ qemuDomainObjPrivatePtr priv = NULL; -+ int rc; -+ int ret = -1; -+ -+ priv = vm->privateData; -+ if (!vm->def->niothreadids) { -+ /* We do not create sub dir for each iothread */ -+ if ((rc = qemuGetVcpuBWLive(priv->cgroup, period, quota)) < 0) -+ goto cleanup; -+ -+ goto out; -+ } -+ -+ /* get period and quota for the "first" IOThread */ -+ if (virCgroupNewThread(priv->cgroup, VIR_CGROUP_THREAD_IOTHREAD, -+ vm->def->iothreadids[0]->iothread_id, -+ false, &cgroup_iothread) < 0) -+ goto cleanup; -+ -+ rc = qemuGetVcpuBWLive(cgroup_iothread, period, quota); -+ if (rc < 0) -+ goto cleanup; -+ -+ out: -+ ret = 0; -+ -+ cleanup: -+ virCgroupFree(&cgroup_iothread); -+ return ret; -+} -+ -+ -+static int - qemuGetGlobalBWLive(virCgroupPtr cgroup, unsigned long long *period, - long long *quota) - { -@@ -10378,6 +10493,11 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom, - qemuGetGlobalBWLive(priv->cgroup, &data.global_period, - &data.global_quota) < 0) - goto cleanup; -+ -+ if (maxparams > 7 && -+ qemuGetIOThreadsBWLive(vm, &data.iothread_period, -+ &data.iothread_quota) < 0) -+ goto cleanup; - } else { - cpu_bw_status = false; - } -@@ -10402,6 +10522,9 @@ qemuDomainGetSchedulerParametersFlags(virDomainPtr dom, - - QEMU_SCHED_ASSIGN(global_period, GLOBAL_PERIOD, ULLONG); - QEMU_SCHED_ASSIGN(global_quota, GLOBAL_QUOTA, LLONG); -+ -+ QEMU_SCHED_ASSIGN(iothread_period, IOTHREAD_PERIOD, ULLONG); -+ QEMU_SCHED_ASSIGN(iothread_quota, IOTHREAD_QUOTA, LLONG); - } - - #undef QEMU_SCHED_ASSIGN -diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c -index 2eac422..9583506 100644 ---- a/src/qemu/qemu_process.c -+++ b/src/qemu/qemu_process.c -@@ -4697,8 +4697,8 @@ qemuProcessSetupIOThread(virDomainObjPtr vm, - VIR_CGROUP_THREAD_IOTHREAD, - iothread->iothread_id, - iothread->cpumask, -- vm->def->cputune.period, -- vm->def->cputune.quota, -+ vm->def->cputune.iothread_period, -+ vm->def->cputune.iothread_quota, - &iothread->sched); - } - --- -2.10.0 - diff --git a/SOURCES/libvirt-qemu-Adjust-the-cur_ballon-on-coldplug-unplug-of-dimms.patch b/SOURCES/libvirt-qemu-Adjust-the-cur_ballon-on-coldplug-unplug-of-dimms.patch deleted file mode 100644 index 6855f9e..0000000 --- a/SOURCES/libvirt-qemu-Adjust-the-cur_ballon-on-coldplug-unplug-of-dimms.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 55801bed29ad9b57d8deca92be44e436c3b60b5e Mon Sep 17 00:00:00 2001 -Message-Id: <55801bed29ad9b57d8deca92be44e436c3b60b5e@dist-git> -From: Shivaprasad G Bhat -Date: Tue, 16 Aug 2016 16:26:38 +0200 -Subject: [PATCH] qemu: Adjust the cur_ballon on coldplug/unplug of dimms - -https://bugzilla.redhat.com/show_bug.cgi?id=1220702 - -The cur_balloon also increases/decreases with dimm hotplug/unplug. -To be consistent, adjust the value for coldplug too. This was inconsistently -taken care when cur_ballon != memory to begin with. The patch fixes it -irrespective of that. - -Signed-off-by: Shivaprasad G Bhat -Signed-off-by: Peter Krempa -(cherry picked from commit 707063efa86a8cab3ee7d64ad203f2e517b82bce) ---- - src/conf/domain_conf.c | 4 ---- - src/qemu/qemu_driver.c | 9 +++++---- - 2 files changed, 5 insertions(+), 8 deletions(-) - -diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c -index 715ca2b..33954f7 100644 ---- a/src/conf/domain_conf.c -+++ b/src/conf/domain_conf.c -@@ -14668,10 +14668,6 @@ virDomainMemoryRemove(virDomainDefPtr def, - - VIR_DELETE_ELEMENT(def->mems, idx, def->nmems); - -- /* fix up balloon size */ -- if (def->mem.cur_balloon > virDomainDefGetMemoryTotal(def)) -- def->mem.cur_balloon = virDomainDefGetMemoryTotal(def); -- - /* fix total memory size of the domain */ - virDomainDefSetMemoryTotal(def, memory - ret->size); - -diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c -index 2fe217d..9c6c1cf 100644 ---- a/src/qemu/qemu_driver.c -+++ b/src/qemu/qemu_driver.c -@@ -7788,8 +7788,7 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - return -1; - } - -- if (vmdef->mem.cur_balloon == virDomainDefGetMemoryTotal(vmdef)) -- vmdef->mem.cur_balloon += dev->data.memory->size; -+ vmdef->mem.cur_balloon += dev->data.memory->size; - - if (virDomainMemoryInsert(vmdef, dev->data.memory) < 0) - return -1; -@@ -7846,6 +7845,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, - virDomainControllerDefPtr cont, det_cont; - virDomainChrDefPtr chr; - virDomainFSDefPtr fs; -+ virDomainMemoryDefPtr mem; - int idx; - - switch ((virDomainDeviceType) dev->type) { -@@ -7943,8 +7943,9 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, - _("matching memory device was not found")); - return -1; - } -- -- virDomainMemoryDefFree(virDomainMemoryRemove(vmdef, idx)); -+ mem = virDomainMemoryRemove(vmdef, idx); -+ vmdef->mem.cur_balloon -= mem->size; -+ virDomainMemoryDefFree(mem); - break; - - case VIR_DOMAIN_DEVICE_REDIRDEV: --- -2.9.2 - diff --git a/SOURCES/libvirt-qemu-Advertise-ACPI-support-for-aarch64-guests.patch b/SOURCES/libvirt-qemu-Advertise-ACPI-support-for-aarch64-guests.patch new file mode 100644 index 0000000..7abbd4f --- /dev/null +++ b/SOURCES/libvirt-qemu-Advertise-ACPI-support-for-aarch64-guests.patch @@ -0,0 +1,139 @@ +From 2106b821cd1eef809853f7424edf8660732b1303 Mon Sep 17 00:00:00 2001 +Message-Id: <2106b821cd1eef809853f7424edf8660732b1303@dist-git> +From: Andrea Bolognani +Date: Tue, 4 Apr 2017 14:59:30 +0200 +Subject: [PATCH] qemu: Advertise ACPI support for aarch64 guests + +So far, libvirt has assumed that only x86 supports ACPI, +but that's inaccurate since aarch64 supports it too. + +Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1429509 + +(cherry picked from commit 560335c35c830344329c16cb1f25f887344bdfd8) +Signed-off-by: Andrea Bolognani +--- + src/qemu/qemu_capabilities.c | 28 ++++++++++++++++------ + .../caps_2.6.0-gicv2.aarch64.xml | 1 + + .../caps_2.6.0-gicv3.aarch64.xml | 1 + + .../qemuxml2argv-aarch64-gic-host.args | 1 + + .../qemuxml2argv-aarch64-gic-v2.args | 1 + + .../qemuxml2argv-aarch64-gic-v3.args | 1 + + 6 files changed, 26 insertions(+), 7 deletions(-) + +diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c +index 9d0a29732..a8125102c 100644 +--- a/src/qemu/qemu_capabilities.c ++++ b/src/qemu/qemu_capabilities.c +@@ -1043,13 +1043,17 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, + + machines = NULL; + nmachines = 0; ++ } + ++ if ((ARCH_IS_X86(guestarch) || guestarch == VIR_ARCH_AARCH64) && ++ virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL) { ++ goto cleanup; + } + + if (ARCH_IS_X86(guestarch) && +- (virCapabilitiesAddGuestFeature(guest, "acpi", true, true) == NULL || +- virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL)) ++ virCapabilitiesAddGuestFeature(guest, "apic", true, false) == NULL) { + goto cleanup; ++ } + + if ((guestarch == VIR_ARCH_I686) && + (virCapabilitiesAddGuestFeature(guest, "pae", true, false) == NULL || +@@ -4181,10 +4185,15 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid, const c + qmperr) < 0) + goto cleanup; + +- /* -no-acpi is not supported on non-x86 +- * even if qemu reports it in -help */ +- if (!ARCH_IS_X86(qemuCaps->arch)) ++ /* Older QEMU versions reported -no-acpi in the output of -help even ++ * though it was not supported by the architecture. The issue has since ++ * been fixed, but to maintain compatibility with all release we still ++ * need to filter out the capability for architectures that we know ++ * don't support the feature, eg. anything but x86 and aarch64 */ ++ if (!ARCH_IS_X86(qemuCaps->arch) && ++ qemuCaps->arch != VIR_ARCH_AARCH64) { + virQEMUCapsClear(qemuCaps, QEMU_CAPS_NO_ACPI); ++ } + + /* virQEMUCapsExtractDeviceStr will only set additional caps if qemu + * understands the 0.13.0+ notion of "-device driver,". */ +@@ -4305,9 +4314,14 @@ virQEMUCapsInitQMPArch(virQEMUCapsPtr qemuCaps, + void + virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps) + { +- /* ACPI/HPET/KVM PIT are x86 specific */ +- if (ARCH_IS_X86(qemuCaps->arch)) { ++ /* ACPI only works on x86 and aarch64 */ ++ if (ARCH_IS_X86(qemuCaps->arch) || ++ qemuCaps->arch == VIR_ARCH_AARCH64) { + virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_ACPI); ++ } ++ ++ /* HPET and KVM PIT are x86 specific */ ++ if (ARCH_IS_X86(qemuCaps->arch)) { + virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_HPET); + virQEMUCapsSet(qemuCaps, QEMU_CAPS_NO_KVM_PIT); + } +diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +index c1e46794a..af3a8e7cb 100644 +--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml ++++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv2.aarch64.xml +@@ -40,6 +40,7 @@ + + + ++ + + + +diff --git a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +index 20dfda216..4402ffa6f 100644 +--- a/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml ++++ b/tests/qemucapabilitiesdata/caps_2.6.0-gicv3.aarch64.xml +@@ -40,6 +40,7 @@ + + + ++ + + + +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args +index 5fdaa08ef..23276ad71 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-host.args +@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \ + -nographic \ + -nodefaults \ + -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \ ++-no-acpi \ + -boot c +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args +index 2caf1b92c..f79c1c60e 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v2.args +@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \ + -nographic \ + -nodefaults \ + -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \ ++-no-acpi \ + -boot c +diff --git a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args +index 3ae8e5f86..fce9308b0 100644 +--- a/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args ++++ b/tests/qemuxml2argvdata/qemuxml2argv-aarch64-gic-v3.args +@@ -15,4 +15,5 @@ QEMU_AUDIO_DRV=none \ + -nographic \ + -nodefaults \ + -monitor unix:/tmp/lib/domain--1-aarch64test/monitor.sock,server,nowait \ ++-no-acpi \ + -boot c +-- +2.12.2 + diff --git a/SOURCES/libvirt-qemu-Advertise-OVMF_CODE.secboot.fd.patch b/SOURCES/libvirt-qemu-Advertise-OVMF_CODE.secboot.fd.patch deleted file mode 100644 index 85255dd..0000000 --- a/SOURCES/libvirt-qemu-Advertise-OVMF_CODE.secboot.fd.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 3d07abddf4b080d2f33c668404d88be5679ec9ee Mon Sep 17 00:00:00 2001 -Message-Id: <3d07abddf4b080d2f33c668404d88be5679ec9ee@dist-git> -From: Michal Privoznik -Date: Fri, 5 Aug 2016 14:35:28 +0200 -Subject: [PATCH] qemu: Advertise OVMF_CODE.secboot.fd - -https://bugzilla.redhat.com/show_bug.cgi?id=1304483 - -Signed-off-by: Michal Privoznik -(cherry picked from commit f522b7d2693f5804e1a12f2c3b0b6e5f4b1c85fd) -Signed-off-by: Michal Privoznik ---- - src/qemu/qemu.conf | 1 + - src/qemu/qemu_conf.c | 13 +++++++++---- - 2 files changed, 10 insertions(+), 4 deletions(-) - -diff --git a/src/qemu/qemu.conf b/src/qemu/qemu.conf -index 7964273..20bfb74 100644 ---- a/src/qemu/qemu.conf -+++ b/src/qemu/qemu.conf -@@ -524,6 +524,7 @@ - # follows this scheme. - #nvram = [ - # "/usr/share/OVMF/OVMF_CODE.fd:/usr/share/OVMF/OVMF_VARS.fd", -+# "/usr/share/OVMF/OVMF_CODE.secboot.fd:/usr/share/OVMF/OVMF_VARS.fd", - # "/usr/share/AAVMF/AAVMF_CODE.fd:/usr/share/AAVMF/AAVMF_VARS.fd" - #] - -diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c -index 49e8e8b..2fd7e51 100644 ---- a/src/qemu/qemu_conf.c -+++ b/src/qemu/qemu_conf.c -@@ -126,6 +126,8 @@ void qemuDomainCmdlineDefFree(qemuDomainCmdlineDefPtr def) - - #define VIR_QEMU_OVMF_LOADER_PATH "/usr/share/OVMF/OVMF_CODE.fd" - #define VIR_QEMU_OVMF_NVRAM_PATH "/usr/share/OVMF/OVMF_VARS.fd" -+#define VIR_QEMU_OVMF_SEC_LOADER_PATH "/usr/share/OVMF/OVMF_CODE.secboot.fd" -+#define VIR_QEMU_OVMF_SEC_NVRAM_PATH "/usr/share/OVMF/OVMF_VARS.fd" - #define VIR_QEMU_AAVMF_LOADER_PATH "/usr/share/AAVMF/AAVMF_CODE.fd" - #define VIR_QEMU_AAVMF_NVRAM_PATH "/usr/share/AAVMF/AAVMF_VARS.fd" - -@@ -292,16 +294,19 @@ virQEMUDriverConfigPtr virQEMUDriverConfigNew(bool privileged) - goto error; - - #else -- if (VIR_ALLOC_N(cfg->firmwares, 2) < 0) -+ if (VIR_ALLOC_N(cfg->firmwares, 3) < 0) - goto error; -- cfg->nfirmwares = 2; -- if (VIR_ALLOC(cfg->firmwares[0]) < 0 || VIR_ALLOC(cfg->firmwares[1]) < 0) -+ cfg->nfirmwares = 3; -+ if (VIR_ALLOC(cfg->firmwares[0]) < 0 || VIR_ALLOC(cfg->firmwares[1]) < 0 || -+ VIR_ALLOC(cfg->firmwares[2]) < 0) - goto error; - - if (VIR_STRDUP(cfg->firmwares[0]->name, VIR_QEMU_AAVMF_LOADER_PATH) < 0 || - VIR_STRDUP(cfg->firmwares[0]->nvram, VIR_QEMU_AAVMF_NVRAM_PATH) < 0 || - VIR_STRDUP(cfg->firmwares[1]->name, VIR_QEMU_OVMF_LOADER_PATH) < 0 || -- VIR_STRDUP(cfg->firmwares[1]->nvram, VIR_QEMU_OVMF_NVRAM_PATH) < 0) -+ VIR_STRDUP(cfg->firmwares[1]->nvram, VIR_QEMU_OVMF_NVRAM_PATH) < 0 || -+ VIR_STRDUP(cfg->firmwares[2]->name, VIR_QEMU_OVMF_SEC_LOADER_PATH) < 0 || -+ VIR_STRDUP(cfg->firmwares[2]->nvram, VIR_QEMU_OVMF_SEC_NVRAM_PATH) < 0) - goto error; - #endif - --- -2.9.2 - diff --git a/SOURCES/libvirt-qemu-Allow-empty-script-path-to-interface.patch b/SOURCES/libvirt-qemu-Allow-empty-script-path-to-interface.patch deleted file mode 100644 index 7ac6f68..0000000 --- a/SOURCES/libvirt-qemu-Allow-empty-script-path-to-interface.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 7a081e92617f2f05e9ef29d3eb65b557e7375815 Mon Sep 17 00:00:00 2001 -Message-Id: <7a081e92617f2f05e9ef29d3eb65b557e7375815@dist-git> -From: Michal Privoznik -Date: Mon, 6 Mar 2017 16:20:57 +0100 -Subject: [PATCH] qemu: Allow empty script path to - -RHEL-7.4: https://bugzilla.redhat.com/show_bug.cgi?id=1412834 -RHEL-7.3.z: https://bugzilla.redhat.com/show_bug.cgi?id=1429510 - -Before 9c17d665fdc5f (v1.3.2 - I know, right?) it was possible to -have the following interface configuration: - - -