mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 05:17:59 +03:00
Pass oldDev to virDomainDefCompatibleDevice on device update
When calling virDomainDefCompatibleDevice to check a new device during device update, we need to pass the original device which is going to be updated in addition to the new device. Otherwise, the function can report false conflicts. The new argument is currently ignored by virDomainDefCompatibleDevice, but this will change in the following patch. https://bugzilla.redhat.com/show_bug.cgi?id=1546971 Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
e3497f3fc8
commit
b6a264e855
@ -27400,7 +27400,8 @@ virDomainDeviceInfoCheckBootIndex(virDomainDefPtr def ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
int
|
int
|
||||||
virDomainDefCompatibleDevice(virDomainDefPtr def,
|
virDomainDefCompatibleDevice(virDomainDefPtr def,
|
||||||
virDomainDeviceDefPtr dev)
|
virDomainDeviceDefPtr dev,
|
||||||
|
virDomainDeviceDefPtr oldDev ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
virDomainDeviceInfoPtr info = virDomainDeviceGetInfo(dev);
|
virDomainDeviceInfoPtr info = virDomainDeviceGetInfo(dev);
|
||||||
|
|
||||||
|
@ -3014,7 +3014,8 @@ typedef enum {
|
|||||||
} virDomainDeviceAction;
|
} virDomainDeviceAction;
|
||||||
|
|
||||||
int virDomainDefCompatibleDevice(virDomainDefPtr def,
|
int virDomainDefCompatibleDevice(virDomainDefPtr def,
|
||||||
virDomainDeviceDefPtr dev);
|
virDomainDeviceDefPtr dev,
|
||||||
|
virDomainDeviceDefPtr oldDev);
|
||||||
|
|
||||||
void virDomainRNGDefFree(virDomainRNGDefPtr def);
|
void virDomainRNGDefFree(virDomainRNGDefPtr def);
|
||||||
|
|
||||||
|
@ -3578,6 +3578,7 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virDomainNetDefPtr net;
|
virDomainNetDefPtr net;
|
||||||
|
virDomainDeviceDef oldDev = { .type = dev->type };
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
switch (dev->type) {
|
switch (dev->type) {
|
||||||
@ -3586,8 +3587,11 @@ lxcDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
if ((idx = virDomainNetFindIdx(vmdef, net)) < 0)
|
if ((idx = virDomainNetFindIdx(vmdef, net)) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virDomainNetDefFree(vmdef->nets[idx]);
|
oldDev.data.net = vmdef->nets[idx];
|
||||||
|
if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
virDomainNetDefFree(vmdef->nets[idx]);
|
||||||
vmdef->nets[idx] = net;
|
vmdef->nets[idx] = net;
|
||||||
dev->data.net = NULL;
|
dev->data.net = NULL;
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -4820,7 +4824,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
|
|||||||
if (!vmdef)
|
if (!vmdef)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
|
if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0)
|
if ((ret = lxcDomainAttachDeviceConfig(vmdef, dev)) < 0)
|
||||||
@ -4828,7 +4832,7 @@ static int lxcDomainAttachDeviceFlags(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
|
if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if ((ret = lxcDomainAttachDeviceLive(dom->conn, driver, vm, dev_copy)) < 0)
|
if ((ret = lxcDomainAttachDeviceLive(dom->conn, driver, vm, dev_copy)) < 0)
|
||||||
@ -4931,9 +4935,8 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
if (!vmdef)
|
if (!vmdef)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
|
/* virDomainDefCompatibleDevice call is delayed until we know the
|
||||||
goto endjob;
|
* device we're going to update. */
|
||||||
|
|
||||||
if ((ret = lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0)
|
if ((ret = lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
@ -7844,6 +7844,7 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
|
|||||||
{
|
{
|
||||||
virDomainDiskDefPtr disk = dev->data.disk;
|
virDomainDiskDefPtr disk = dev->data.disk;
|
||||||
virDomainDiskDefPtr orig_disk = NULL;
|
virDomainDiskDefPtr orig_disk = NULL;
|
||||||
|
virDomainDeviceDef oldDev = { .type = dev->type };
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
if (virDomainDiskTranslateSourcePool(disk) < 0)
|
||||||
@ -7861,6 +7862,10 @@ qemuDomainChangeDiskLive(virDomainObjPtr vm,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldDev.data.disk = orig_disk;
|
||||||
|
if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev) < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
if (!qemuDomainDiskChangeSupported(disk, orig_disk))
|
if (!qemuDomainDiskChangeSupported(disk, orig_disk))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -7903,19 +7908,36 @@ qemuDomainUpdateDeviceLive(virDomainObjPtr vm,
|
|||||||
bool force)
|
bool force)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = dom->conn->privateData;
|
virQEMUDriverPtr driver = dom->conn->privateData;
|
||||||
|
virDomainDeviceDef oldDev = { .type = dev->type };
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
int idx;
|
||||||
|
|
||||||
switch ((virDomainDeviceType) dev->type) {
|
switch ((virDomainDeviceType) dev->type) {
|
||||||
case VIR_DOMAIN_DEVICE_DISK:
|
case VIR_DOMAIN_DEVICE_DISK:
|
||||||
qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL);
|
qemuDomainObjCheckDiskTaint(driver, vm, dev->data.disk, NULL);
|
||||||
ret = qemuDomainChangeDiskLive(vm, dev, driver, force);
|
ret = qemuDomainChangeDiskLive(vm, dev, driver, force);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
case VIR_DOMAIN_DEVICE_GRAPHICS:
|
||||||
|
if ((idx = qemuDomainFindGraphicsIndex(vm->def, dev->data.graphics) >= 0)) {
|
||||||
|
oldDev.data.graphics = vm->def->graphics[idx];
|
||||||
|
if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics);
|
ret = qemuDomainChangeGraphics(driver, vm, dev->data.graphics);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_NET:
|
case VIR_DOMAIN_DEVICE_NET:
|
||||||
|
if ((idx = virDomainNetFindIdx(vm->def, dev->data.net)) >= 0) {
|
||||||
|
oldDev.data.net = vm->def->nets[idx];
|
||||||
|
if (virDomainDefCompatibleDevice(vm->def, dev, &oldDev) < 0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
ret = qemuDomainChangeNet(driver, vm, dev);
|
ret = qemuDomainChangeNet(driver, vm, dev);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VIR_DOMAIN_DEVICE_FS:
|
case VIR_DOMAIN_DEVICE_FS:
|
||||||
case VIR_DOMAIN_DEVICE_INPUT:
|
case VIR_DOMAIN_DEVICE_INPUT:
|
||||||
case VIR_DOMAIN_DEVICE_SOUND:
|
case VIR_DOMAIN_DEVICE_SOUND:
|
||||||
@ -8329,6 +8351,7 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
virDomainDiskDefPtr newDisk;
|
virDomainDiskDefPtr newDisk;
|
||||||
virDomainGraphicsDefPtr newGraphics;
|
virDomainGraphicsDefPtr newGraphics;
|
||||||
virDomainNetDefPtr net;
|
virDomainNetDefPtr net;
|
||||||
|
virDomainDeviceDef oldDev = { .type = dev->type };
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
switch ((virDomainDeviceType) dev->type) {
|
switch ((virDomainDeviceType) dev->type) {
|
||||||
@ -8340,6 +8363,10 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
oldDev.data.disk = vmdef->disks[pos];
|
||||||
|
if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
virDomainDiskDefFree(vmdef->disks[pos]);
|
virDomainDiskDefFree(vmdef->disks[pos]);
|
||||||
vmdef->disks[pos] = newDisk;
|
vmdef->disks[pos] = newDisk;
|
||||||
dev->data.disk = NULL;
|
dev->data.disk = NULL;
|
||||||
@ -8355,8 +8382,11 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
virDomainGraphicsDefFree(vmdef->graphics[pos]);
|
oldDev.data.graphics = vmdef->graphics[pos];
|
||||||
|
if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
virDomainGraphicsDefFree(vmdef->graphics[pos]);
|
||||||
vmdef->graphics[pos] = newGraphics;
|
vmdef->graphics[pos] = newGraphics;
|
||||||
dev->data.graphics = NULL;
|
dev->data.graphics = NULL;
|
||||||
break;
|
break;
|
||||||
@ -8366,8 +8396,11 @@ qemuDomainUpdateDeviceConfig(virDomainDefPtr vmdef,
|
|||||||
if ((pos = virDomainNetFindIdx(vmdef, net)) < 0)
|
if ((pos = virDomainNetFindIdx(vmdef, net)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
virDomainNetDefFree(vmdef->nets[pos]);
|
oldDev.data.net = vmdef->nets[pos];
|
||||||
|
if (virDomainDefCompatibleDevice(vmdef, dev, &oldDev) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
virDomainNetDefFree(vmdef->nets[pos]);
|
||||||
vmdef->nets[pos] = net;
|
vmdef->nets[pos] = net;
|
||||||
dev->data.net = NULL;
|
dev->data.net = NULL;
|
||||||
break;
|
break;
|
||||||
@ -8454,7 +8487,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
|
|||||||
if (!vmdef)
|
if (!vmdef)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
|
if (virDomainDefCompatibleDevice(vmdef, dev, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps,
|
if ((ret = qemuDomainAttachDeviceConfig(vmdef, dev, caps,
|
||||||
parse_flags,
|
parse_flags,
|
||||||
@ -8463,7 +8496,7 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
|
if (virDomainDefCompatibleDevice(vm->def, dev_copy, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, driver)) < 0)
|
if ((ret = qemuDomainAttachDeviceLive(vm, dev_copy, driver)) < 0)
|
||||||
@ -8603,9 +8636,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
if (!vmdef)
|
if (!vmdef)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (virDomainDefCompatibleDevice(vmdef, dev) < 0)
|
/* virDomainDefCompatibleDevice call is delayed until we know the
|
||||||
goto endjob;
|
* device we're going to update. */
|
||||||
|
|
||||||
if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps,
|
if ((ret = qemuDomainUpdateDeviceConfig(vmdef, dev, caps,
|
||||||
parse_flags,
|
parse_flags,
|
||||||
driver->xmlopt)) < 0)
|
driver->xmlopt)) < 0)
|
||||||
@ -8613,9 +8645,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
if (flags & VIR_DOMAIN_AFFECT_LIVE) {
|
||||||
if (virDomainDefCompatibleDevice(vm->def, dev_copy) < 0)
|
/* virDomainDefCompatibleDevice call is delayed until we know the
|
||||||
goto endjob;
|
* device we're going to update. */
|
||||||
|
|
||||||
if ((ret = qemuDomainUpdateDeviceLive(vm, dev_copy, dom, force)) < 0)
|
if ((ret = qemuDomainUpdateDeviceLive(vm, dev_copy, dom, force)) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user