mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
qemu: validate: Prefer existing qemuCaps
The validation callback always fetched a fresh copy of 'qemuCaps' to use for validation which is wrong in cases when the VM is already running, such as device hotplug. The newly-fetched qemuCaps may contain flags which weren't originally in use when starting the VM e.g. on a libvirtd upgrade. Since the post-parse/validation machinery has a per-run 'parseOpaque' field filled with qemuCaps of the actual process we can reuse the caps in cases when we get them. The code still fetches a fresh copy if parseOpaque doesn't have a per-run copy to preserve existing functionality. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
19af0b6e93
commit
7e9d180100
@ -1067,17 +1067,22 @@ qemuValidateDomainDefPanic(const virDomainDef *def,
|
||||
int
|
||||
qemuValidateDomainDef(const virDomainDef *def,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
void *parseOpaque)
|
||||
{
|
||||
virQEMUDriverPtr driver = opaque;
|
||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
||||
g_autoptr(virQEMUCaps) qemuCapsLocal = NULL;
|
||||
virQEMUCapsPtr qemuCaps = parseOpaque;
|
||||
size_t i;
|
||||
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
|
||||
if (!qemuCaps) {
|
||||
if (!(qemuCapsLocal = virQEMUCapsCacheLookup(driver->qemuCapsCache,
|
||||
def->emulator)))
|
||||
return -1;
|
||||
|
||||
qemuCaps = qemuCapsLocal;
|
||||
}
|
||||
|
||||
if (def->os.type != VIR_DOMAIN_OSTYPE_HVM) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Emulator '%s' does not support os type '%s'"),
|
||||
@ -4666,16 +4671,21 @@ int
|
||||
qemuValidateDomainDeviceDef(const virDomainDeviceDef *dev,
|
||||
const virDomainDef *def,
|
||||
void *opaque,
|
||||
void *parseOpaque G_GNUC_UNUSED)
|
||||
void *parseOpaque)
|
||||
{
|
||||
int ret = 0;
|
||||
virQEMUDriverPtr driver = opaque;
|
||||
g_autoptr(virQEMUCaps) qemuCaps = NULL;
|
||||
g_autoptr(virQEMUCaps) qemuCapsLocal = NULL;
|
||||
virQEMUCapsPtr qemuCaps = parseOpaque;
|
||||
|
||||
if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache,
|
||||
if (!qemuCaps) {
|
||||
if (!(qemuCapsLocal = virQEMUCapsCacheLookup(driver->qemuCapsCache,
|
||||
def->emulator)))
|
||||
return -1;
|
||||
|
||||
qemuCaps = qemuCapsLocal;
|
||||
}
|
||||
|
||||
if ((ret = qemuValidateDomainDeviceDefAddress(dev, qemuCaps)) < 0)
|
||||
return ret;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user