提交 03caa543 编写于 作者: M Martin Kletzander

conf: Add device-related code for panic devices

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1169183Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
上级 bfeee8de
...@@ -257,7 +257,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, ...@@ -257,7 +257,8 @@ VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST,
"nvram", "nvram",
"rng", "rng",
"shmem", "shmem",
"tpm") "tpm",
"panic")
VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST, VIR_ENUM_IMPL(virDomainDeviceAddress, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST,
"none", "none",
...@@ -1946,6 +1947,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def) ...@@ -1946,6 +1947,9 @@ void virDomainDeviceDefFree(virDomainDeviceDefPtr def)
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
virDomainTPMDefFree(def->data.tpm); virDomainTPMDefFree(def->data.tpm);
break; break;
case VIR_DOMAIN_DEVICE_PANIC:
virDomainPanicDefFree(def->data.panic);
break;
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
break; break;
...@@ -2649,6 +2653,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device) ...@@ -2649,6 +2653,8 @@ virDomainDeviceGetInfo(virDomainDeviceDefPtr device)
return &device->data.rng->info; return &device->data.rng->info;
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
return &device->data.tpm->info; return &device->data.tpm->info;
case VIR_DOMAIN_DEVICE_PANIC:
return &device->data.panic->info;
/* The following devices do not contain virDomainDeviceInfo */ /* The following devices do not contain virDomainDeviceInfo */
case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_LEASE:
...@@ -2873,6 +2879,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, ...@@ -2873,6 +2879,12 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
if (cb(def, &device, &def->tpm->info, opaque) < 0) if (cb(def, &device, &def->tpm->info, opaque) < 0)
return -1; 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 */ /* Coverity is not very happy with this - all dead_error_condition */
#if !STATIC_ANALYSIS #if !STATIC_ANALYSIS
...@@ -2903,6 +2915,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def, ...@@ -2903,6 +2915,7 @@ virDomainDeviceInfoIterateInternal(virDomainDefPtr def,
case VIR_DOMAIN_DEVICE_NVRAM: case VIR_DOMAIN_DEVICE_NVRAM:
case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_SHMEM:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_RNG:
break; break;
...@@ -8675,6 +8688,23 @@ virDomainTPMDefParseXML(xmlNodePtr node, ...@@ -8675,6 +8688,23 @@ virDomainTPMDefParseXML(xmlNodePtr node,
goto cleanup; 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 */ /* Parse the XML definition for an input device */
static virDomainInputDefPtr static virDomainInputDefPtr
virDomainInputDefParseXML(const virDomainDef *dom, virDomainInputDefParseXML(const virDomainDef *dom,
...@@ -10931,6 +10961,10 @@ virDomainDeviceDefParse(const char *xmlStr, ...@@ -10931,6 +10961,10 @@ virDomainDeviceDefParse(const char *xmlStr,
if (!(dev->data.tpm = virDomainTPMDefParseXML(node, ctxt, flags))) if (!(dev->data.tpm = virDomainTPMDefParseXML(node, ctxt, flags)))
goto error; goto error;
break; break;
case VIR_DOMAIN_DEVICE_PANIC:
if (!(dev->data.panic = virDomainPanicDefParseXML(node)))
goto error;
break;
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
break; break;
...@@ -12025,23 +12059,6 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, ...@@ -12025,23 +12059,6 @@ virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
return idmap; 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. /* Parse the XML definition for a vcpupin or emulatorpin.
* *
* vcpupin has the form of * vcpupin has the form of
...@@ -15297,6 +15314,13 @@ virDomainTPMDefCheckABIStability(virDomainTPMDefPtr src, ...@@ -15297,6 +15314,13 @@ virDomainTPMDefCheckABIStability(virDomainTPMDefPtr src,
return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); 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 /* This compares two configurations and looks for any differences
* which will affect the guest ABI. This is primarily to allow * which will affect the guest ABI. This is primarily to allow
* validation of custom XML config passed in during migration * validation of custom XML config passed in during migration
...@@ -15720,6 +15744,16 @@ virDomainDefCheckABIStability(virDomainDefPtr src, ...@@ -15720,6 +15744,16 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
goto error; 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 */ /* Coverity is not very happy with this - all dead_error_condition */
#if !STATIC_ANALYSIS #if !STATIC_ANALYSIS
/* This switch statement is here to trigger compiler warning when adding /* This switch statement is here to trigger compiler warning when adding
...@@ -15749,6 +15783,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src, ...@@ -15749,6 +15783,7 @@ virDomainDefCheckABIStability(virDomainDefPtr src,
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_RNG:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_SHMEM:
break; break;
} }
...@@ -18032,7 +18067,7 @@ virDomainWatchdogDefFormat(virBufferPtr buf, ...@@ -18032,7 +18067,7 @@ virDomainWatchdogDefFormat(virBufferPtr buf,
} }
static int virDomainPanicDefFormat(virBufferPtr buf, static int virDomainPanicDefFormat(virBufferPtr buf,
virDomainPanicDefPtr def) virDomainPanicDefPtr def)
{ {
virBufferAddLit(buf, "<panic>\n"); virBufferAddLit(buf, "<panic>\n");
virBufferAdjustIndent(buf, 2); virBufferAdjustIndent(buf, 2);
...@@ -21084,6 +21119,9 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src, ...@@ -21084,6 +21119,9 @@ virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
rc = virDomainTPMDefFormat(&buf, src->data.tpm, flags); rc = virDomainTPMDefFormat(&buf, src->data.tpm, flags);
break; break;
case VIR_DOMAIN_DEVICE_PANIC:
rc = virDomainPanicDefFormat(&buf, src->data.panic);
break;
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_SMARTCARD: case VIR_DOMAIN_DEVICE_SMARTCARD:
case VIR_DOMAIN_DEVICE_MEMBALLOON: case VIR_DOMAIN_DEVICE_MEMBALLOON:
......
...@@ -165,6 +165,7 @@ typedef enum { ...@@ -165,6 +165,7 @@ typedef enum {
VIR_DOMAIN_DEVICE_RNG, VIR_DOMAIN_DEVICE_RNG,
VIR_DOMAIN_DEVICE_SHMEM, VIR_DOMAIN_DEVICE_SHMEM,
VIR_DOMAIN_DEVICE_TPM, VIR_DOMAIN_DEVICE_TPM,
VIR_DOMAIN_DEVICE_PANIC,
VIR_DOMAIN_DEVICE_LAST VIR_DOMAIN_DEVICE_LAST
} virDomainDeviceType; } virDomainDeviceType;
...@@ -194,6 +195,7 @@ struct _virDomainDeviceDef { ...@@ -194,6 +195,7 @@ struct _virDomainDeviceDef {
virDomainRNGDefPtr rng; virDomainRNGDefPtr rng;
virDomainShmemDefPtr shmem; virDomainShmemDefPtr shmem;
virDomainTPMDefPtr tpm; virDomainTPMDefPtr tpm;
virDomainPanicDefPtr panic;
} data; } data;
}; };
......
...@@ -7020,6 +7020,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm, ...@@ -7020,6 +7020,7 @@ qemuDomainAttachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_RNG:
case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_SHMEM:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("live attach of device '%s' is not supported"), _("live attach of device '%s' is not supported"),
...@@ -7095,6 +7096,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm, ...@@ -7095,6 +7096,7 @@ qemuDomainDetachDeviceLive(virDomainObjPtr vm,
case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("live detach of device '%s' is not supported"), _("live detach of device '%s' is not supported"),
...@@ -7205,6 +7207,7 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn, ...@@ -7205,6 +7207,7 @@ qemuDomainUpdateDeviceLive(virConnectPtr conn,
case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_CHR:
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("live update of device '%s' is not supported"), _("live update of device '%s' is not supported"),
...@@ -7336,6 +7339,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps, ...@@ -7336,6 +7339,7 @@ qemuDomainAttachDeviceConfig(virQEMUCapsPtr qemuCaps,
case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("persistent attach of device '%s' is not supported"), _("persistent attach of device '%s' is not supported"),
...@@ -7451,6 +7455,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, ...@@ -7451,6 +7455,7 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef,
case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_REDIRDEV:
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("persistent detach of device '%s' is not supported"), _("persistent detach of device '%s' is not supported"),
...@@ -7537,6 +7542,7 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps, ...@@ -7537,6 +7542,7 @@ qemuDomainUpdateDeviceConfig(virQEMUCapsPtr qemuCaps,
case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_CHR:
case VIR_DOMAIN_DEVICE_NONE: case VIR_DOMAIN_DEVICE_NONE:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("persistent update of device '%s' is not supported"), _("persistent update of device '%s' is not supported"),
......
...@@ -2898,6 +2898,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, ...@@ -2898,6 +2898,7 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_RNG:
case VIR_DOMAIN_DEVICE_SHMEM: case VIR_DOMAIN_DEVICE_SHMEM:
case VIR_DOMAIN_DEVICE_TPM: case VIR_DOMAIN_DEVICE_TPM:
case VIR_DOMAIN_DEVICE_PANIC:
case VIR_DOMAIN_DEVICE_LAST: case VIR_DOMAIN_DEVICE_LAST:
virReportError(VIR_ERR_OPERATION_UNSUPPORTED, virReportError(VIR_ERR_OPERATION_UNSUPPORTED,
_("don't know how to remove a %s device"), _("don't know how to remove a %s device"),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册