Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx> --- src/conf/domain_conf.c | 76 ++++++++++++++++++++++++++++++++++++------------- src/conf/domain_conf.h | 2 ++ src/qemu/qemu_driver.c | 6 ++++ src/qemu/qemu_hotplug.c | 1 + 4 files changed, 66 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 7cfee6e..b0caa76 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -257,7 +257,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, "nvram", "rng", "shmem", - "tpm") + "tpm", + "panic") VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, "none", @@ -1946,6 +1947,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) case VIR_DOMAIN_DEVICE_TPM: virDomainTPMDefFree(def->data.tpm); break; + case VIR_DOMAIN_DEVICE_PANIC: + virDomainPanicDefFree(def->data.panic); + break; case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_NONE: break; @@ -2649,6 +2653,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device) return &device->data.rng->info; case VIR_DOMAIN_DEVICE_TPM: return &device->data.tpm->info; + case VIR_DOMAIN_DEVICE_PANIC: + return &device->data.panic->info; /* The following devices do not contain virDomainDeviceInfo */ case VIR_DOMAIN_DEVICE_LEASE: @@ -2873,6 +2879,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, if (cb(def, &device, &def->tpm->info, opaque) < 0) return -1; } + if (def->panic) { + device.type = VIR_DOMAIN_DEVICE_PANIC; + device.data.panic = def->panic; + if (cb(def, &device, &def->panic->info, opaque) < 0) + return -1; + } /* Coverity is not very happy with this - all dead_error_condition */ #if !STATIC_ANALYSIS @@ -2903,6 +2915,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_RNG: break; @@ -8675,6 +8688,23 @@ virDomainTPMDefParseXML(xmlNodePtr node, goto cleanup; } +static virDomainPanicDefPtr +virDomainPanicDefParseXML(xmlNodePtr node) +{ + virDomainPanicDefPtr panic; + + if (VIR_ALLOC(panic) < 0) + return NULL; + + if (virDomainDeviceInfoParseXML(node, NULL, &panic->info, 0) < 0) + goto error; + + return panic; + error: + virDomainPanicDefFree(panic); + return NULL; +} + /* Parse the XML definition for an input device */ static virDomainInputDefPtr virDomainInputDefParseXML(const virDomainDef *dom, @@ -10931,6 +10961,10 @@ virDomainDeviceDefParse(const char *xmlStr, if (!(dev->data.tpm = virDomainTPMDefParseXML(node, ctxt, flags))) goto error; break; + case VIR_DOMAIN_DEVICE_PANIC: + if (!(dev->data.panic = virDomainPanicDefParseXML(node))) + goto error; + break; case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_LAST: break; @@ -12025,23 +12059,6 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, return idmap; } -static virDomainPanicDefPtr -virDomainPanicDefParseXML(xmlNodePtr node) -{ - virDomainPanicDefPtr panic; - - if (VIR_ALLOC(panic) < 0) - return NULL; - - if (virDomainDeviceInfoParseXML(node, NULL, &panic->info, 0) < 0) - goto error; - - return panic; - error: - virDomainPanicDefFree(panic); - return NULL; -} - /* Parse the XML definition for a vcpupin or emulatorpin. * * vcpupin has the form of @@ -15297,6 +15314,13 @@ virDomainTPMDefCheckABIStability(virDomainTPMDefPtr src, return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } +static bool +virDomainPanicDefCheckABIStability(virDomainPanicDefPtr src, + virDomainPanicDefPtr dst) +{ + return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); +} + /* This compares two configurations and looks for any differences * which will affect the guest ABI. This is primarily to allow * validation of custom XML config passed in during migration @@ -15720,6 +15744,16 @@ virDomainDefCheckABIStability(virDomainDefPtr src, goto error; } + if (src->panic && dst->panic) { + if (!virDomainPanicDefCheckABIStability(src->panic, dst->panic)) + goto error; + } else if (src->panic || dst->panic) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Either both target and source domains or none of " + "them must have PANIC device present")); + 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 @@ -15749,6 +15783,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src, case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_SHMEM: break; } @@ -18032,7 +18067,7 @@ virDomainWatchdogDefFormat(virBufferPtr buf, } static int virDomainPanicDefFormat(virBufferPtr buf, - virDomainPanicDefPtr def) + virDomainPanicDefPtr def) { virBufferAddLit(buf, "<panic>\n"); virBufferAdjustIndent(buf, 2); @@ -21084,6 +21119,9 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, case VIR_DOMAIN_DEVICE_TPM: rc = virDomainTPMDefFormat(&buf, src->data.tpm, flags); break; + case VIR_DOMAIN_DEVICE_PANIC: + rc = virDomainPanicDefFormat(&buf, src->data.panic); + break; case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_MEMBALLOON: diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index b4b1020..4ef2300 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -165,6 +165,7 @@ typedef enum { VIR_DOMAIN_DEVICE_RNG, VIR_DOMAIN_DEVICE_SHMEM, VIR_DOMAIN_DEVICE_TPM, + VIR_DOMAIN_DEVICE_PANIC, VIR_DOMAIN_DEVICE_LAST } virDomainDeviceType; @@ -194,6 +195,7 @@ struct _virDomainDeviceDef { virDomainRNGDefPtr rng; virDomainShmemDefPtr shmem; virDomainTPMDefPtr tpm; + virDomainPanicDefPtr panic; } data; }; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 35223e9..a956c59 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -7020,6 +7020,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("live attach of device '%s' is not supported"), @@ -7095,6 +7096,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("live detach of device '%s' is not supported"), @@ -7205,6 +7207,7 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn, case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("live update of device '%s' is not supported"), @@ -7336,6 +7339,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("persistent attach of device '%s' is not supported"), @@ -7451,6 +7455,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("persistent detach of device '%s' is not supported"), @@ -7537,6 +7542,7 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps, case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: 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 b893428..f2740f4 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2898,6 +2898,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: case VIR_DOMAIN_DEVICE_LAST: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("don't know how to remove a %s device"), -- 2.1.3 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list