[libvirt] [PATCH v3 0/2] default USB controller for PPC

Pavel Hrdina (2): conf: add a new parse flag VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION qemu_domain: use correct default USB controller on ppc64 src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 4 ++++ src/qemu/qemu_domain.c | 16 ++++++++++++---- src/qemu/qemu_migration_cookie.c | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) -- 2.12.2

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 <phrdina@redhat.com> --- 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 d660c06e0f..206b561589 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3818,7 +3818,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 <memory> 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 26c0e6b887..7da554f8ee 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2726,6 +2726,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 bd12f11246..12887892db 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

The history of USB controller for ppc64 guest is complex and goes back to libvirt 1.3.1 where the fun started. Prior Libvirt 1.3.1 if no model for USB controller was specified we've simply passed "-usb" on QEMU command line. Since Libvirt 1.3.1 there is a patch (8156493d8db) that fixes this issue by using "-device pci-ohci,..." but it breaks migration with older Libvirts which was agreed that's acceptable. However this patch didn't reflect this change in the domain XML and the model was still missing. Since Libvirt 2.2.0 there is a patch (f55eaccb0c5) that fixes the issue with not setting the USB model into domain XML which we need to know about to not break the migration and since the default model was *pci-ohci* it was used as default in this patch as well. This patch tries to take all the previous changes into account and also change the default for newly defined domains that don't specify any model for USB controller. The VIR_DOMAIN_DEF_PARSE_ABI_UPDATE is set only if new domain is defined or new device is added into a domain which means that in all other cases we will use the old *pci-ohci* model instead of the better and not broken *nec-usb-xhci* model. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1373184 Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_domain.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 39bc8c7483..1aff774012 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -3141,7 +3141,8 @@ qemuDomainShmemDefPostParse(virDomainShmemDefPtr shm) static int qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, const virDomainDef *def, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps, + unsigned int parseFlags) { switch ((virDomainControllerType)cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: @@ -3169,9 +3170,16 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont, * address is found */ cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE; } else if (ARCH_IS_PPC64(def->os.arch)) { - /* Default USB controller for ppc64 is pci-ohci */ - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) + /* To not break migration we need to set default USB controller + * for ppc64 to pci-ohci if we cannot change ABI of the VM. + * The nec-usb-xhci controller is used as default only for + * newly defined domains or devices. */ + if ((parseFlags & VIR_DOMAIN_DEF_PARSE_ABI_UPDATE) && + virQEMUCapsGet(qemuCaps, QEMU_CAPS_NEC_USB_XHCI)) { + cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_NEC_XHCI; + } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PCI_OHCI)) { cont->model = VIR_DOMAIN_CONTROLLER_MODEL_USB_PCI_OHCI; + } } else { /* Default USB controller for anything else is piix3-uhci */ if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_PIIX3_USB_UHCI)) @@ -3370,7 +3378,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, if (dev->type == VIR_DOMAIN_DEVICE_CONTROLLER && qemuDomainControllerDefPostParse(dev->data.controller, def, - qemuCaps) < 0) + qemuCaps, parseFlags) < 0) goto cleanup; if (dev->type == VIR_DOMAIN_DEVICE_SHMEM && -- 2.12.2

On Thu, 2017-04-13 at 13:27 +0200, Pavel Hrdina wrote:
Pavel Hrdina (2): conf: add a new parse flag VIR_DOMAIN_DEF_PARSE_ABI_UPDATE_MIGRATION qemu_domain: use correct default USB controller on ppc64 src/conf/domain_conf.c | 3 ++- src/conf/domain_conf.h | 4 ++++ src/qemu/qemu_domain.c | 16 ++++++++++++---- src/qemu/qemu_migration_cookie.c | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-)
I've tested this by migrating guests from libvirt 2.1.0 and 2.2.0, and in both cases it worked as advertised. ACK series. -- Andrea Bolognani / Red Hat / Virtualization
participants (2)
-
Andrea Bolognani
-
Pavel Hrdina