mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-08 16:54:49 +00:00
conf: Add device-related code for panic devices
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1169183 Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
bfeee8dee4
commit
03caa543c2
@ -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:
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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"),
|
||||
|
@ -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"),
|
||||
|
Loading…
Reference in New Issue
Block a user