mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-15 09:05:16 +00:00
qemu: hotplug: Use VIR_AUTOFREE() instead VIR_FREE for strings
Cleanup labels are also dropped where possible. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
15340ff583
commit
87ecf62d4c
@ -136,20 +136,15 @@ static int
|
|||||||
qemuDomainAttachZPCIDevice(qemuMonitorPtr mon,
|
qemuDomainAttachZPCIDevice(qemuMonitorPtr mon,
|
||||||
virDomainDeviceInfoPtr info)
|
virDomainDeviceInfoPtr info)
|
||||||
{
|
{
|
||||||
char *devstr_zpci = NULL;
|
VIR_AUTOFREE(char *) devstr_zpci = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!(devstr_zpci = qemuBuildZPCIDevStr(info)))
|
if (!(devstr_zpci = qemuBuildZPCIDevStr(info)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorAddDevice(mon, devstr_zpci) < 0)
|
if (qemuMonitorAddDevice(mon, devstr_zpci) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(devstr_zpci);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -157,20 +152,15 @@ static int
|
|||||||
qemuDomainDetachZPCIDevice(qemuMonitorPtr mon,
|
qemuDomainDetachZPCIDevice(qemuMonitorPtr mon,
|
||||||
virDomainDeviceInfoPtr info)
|
virDomainDeviceInfoPtr info)
|
||||||
{
|
{
|
||||||
char *zpciAlias = NULL;
|
VIR_AUTOFREE(char *) zpciAlias = NULL;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (virAsprintf(&zpciAlias, "zpci%d", info->addr.pci.zpci.uid) < 0)
|
if (virAsprintf(&zpciAlias, "zpci%d", info->addr.pci.zpci.uid) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorDelDevice(mon, zpciAlias) < 0)
|
if (qemuMonitorDelDevice(mon, zpciAlias) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(zpciAlias);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -517,31 +507,30 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
|
|||||||
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
qemuDomainDiskPrivatePtr diskPriv = QEMU_DOMAIN_DISK_PRIVATE(disk);
|
||||||
VIR_AUTOPTR(qemuBlockStorageSourceChainData) newbackend = NULL;
|
VIR_AUTOPTR(qemuBlockStorageSourceChainData) newbackend = NULL;
|
||||||
VIR_AUTOPTR(qemuBlockStorageSourceChainData) oldbackend = NULL;
|
VIR_AUTOPTR(qemuBlockStorageSourceChainData) oldbackend = NULL;
|
||||||
char *nodename = NULL;
|
VIR_AUTOFREE(char *) nodename = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!virStorageSourceIsEmpty(oldsrc) &&
|
if (!virStorageSourceIsEmpty(oldsrc) &&
|
||||||
!(oldbackend = qemuBlockStorageSourceChainDetachPrepareBlockdev(oldsrc)))
|
!(oldbackend = qemuBlockStorageSourceChainDetachPrepareBlockdev(oldsrc)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!virStorageSourceIsEmpty(newsrc)) {
|
if (!virStorageSourceIsEmpty(newsrc)) {
|
||||||
if (!(newbackend = qemuBuildStorageSourceChainAttachPrepareBlockdev(newsrc,
|
if (!(newbackend = qemuBuildStorageSourceChainAttachPrepareBlockdev(newsrc,
|
||||||
priv->qemuCaps)))
|
priv->qemuCaps)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainDiskGetBackendAlias(disk, priv->qemuCaps, &nodename) < 0)
|
if (qemuDomainDiskGetBackendAlias(disk, priv->qemuCaps, &nodename) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diskPriv->tray && disk->tray_status != VIR_DOMAIN_DISK_TRAY_OPEN) {
|
if (diskPriv->tray && disk->tray_status != VIR_DOMAIN_DISK_TRAY_OPEN) {
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
rc = qemuMonitorBlockdevTrayOpen(priv->mon, diskPriv->qomName, force);
|
rc = qemuMonitorBlockdevTrayOpen(priv->mon, diskPriv->qomName, force);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!force && qemuHotplugWaitForTrayEject(vm, disk) < 0)
|
if (!force && qemuHotplugWaitForTrayEject(vm, disk) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
@ -567,13 +556,9 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver,
|
|||||||
qemuBlockStorageSourceChainDetach(priv->mon, newbackend);
|
qemuBlockStorageSourceChainDetach(priv->mon, newbackend);
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(nodename);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -823,7 +808,7 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
const char* type = virDomainControllerTypeToString(controller->type);
|
const char* type = virDomainControllerTypeToString(controller->type);
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_CONTROLLER,
|
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_CONTROLLER,
|
||||||
{ .controller = controller } };
|
{ .controller = controller } };
|
||||||
@ -890,7 +875,6 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver,
|
|||||||
if (ret != 0 && releaseaddr)
|
if (ret != 0 && releaseaddr)
|
||||||
qemuDomainReleaseDeviceAddress(vm, &controller->info);
|
qemuDomainReleaseDeviceAddress(vm, &controller->info);
|
||||||
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1156,8 +1140,8 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
int *vhostfd = NULL;
|
int *vhostfd = NULL;
|
||||||
size_t vhostfdSize = 0;
|
size_t vhostfdSize = 0;
|
||||||
size_t queueSize = 0;
|
size_t queueSize = 0;
|
||||||
char *nicstr = NULL;
|
VIR_AUTOFREE(char *) nicstr = NULL;
|
||||||
char *netstr = NULL;
|
VIR_AUTOFREE(char *) netstr = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
bool releaseaddr = false;
|
bool releaseaddr = false;
|
||||||
bool iface_connected = false;
|
bool iface_connected = false;
|
||||||
@ -1166,10 +1150,10 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
||||||
virDomainCCWAddressSetPtr ccwaddrs = NULL;
|
virDomainCCWAddressSetPtr ccwaddrs = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
char *charDevAlias = NULL;
|
VIR_AUTOFREE(char *) charDevAlias = NULL;
|
||||||
bool charDevPlugged = false;
|
bool charDevPlugged = false;
|
||||||
bool netdevPlugged = false;
|
bool netdevPlugged = false;
|
||||||
char *netdev_name;
|
VIR_AUTOFREE(char *) netdev_name = NULL;
|
||||||
virConnectPtr conn = NULL;
|
virConnectPtr conn = NULL;
|
||||||
virErrorPtr save_err = NULL;
|
virErrorPtr save_err = NULL;
|
||||||
|
|
||||||
@ -1499,8 +1483,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
virErrorRestore(&save_err);
|
virErrorRestore(&save_err);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(nicstr);
|
|
||||||
VIR_FREE(netstr);
|
|
||||||
for (i = 0; tapfd && i < tapfdSize; i++) {
|
for (i = 0; tapfd && i < tapfdSize; i++) {
|
||||||
VIR_FORCE_CLOSE(tapfd[i]);
|
VIR_FORCE_CLOSE(tapfd[i]);
|
||||||
if (tapfdName)
|
if (tapfdName)
|
||||||
@ -1515,7 +1497,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
VIR_FREE(vhostfd);
|
VIR_FREE(vhostfd);
|
||||||
VIR_FREE(vhostfdName);
|
VIR_FREE(vhostfdName);
|
||||||
VIR_FREE(charDevAlias);
|
|
||||||
virObjectUnref(conn);
|
virObjectUnref(conn);
|
||||||
virDomainCCWAddressSetFree(ccwaddrs);
|
virDomainCCWAddressSetFree(ccwaddrs);
|
||||||
VIR_FORCE_CLOSE(slirpfd);
|
VIR_FORCE_CLOSE(slirpfd);
|
||||||
@ -1539,7 +1520,6 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver,
|
|||||||
VIR_WARN("Failed to remove network backend for netdev %s",
|
VIR_WARN("Failed to remove network backend for netdev %s",
|
||||||
netdev_name);
|
netdev_name);
|
||||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||||
VIR_FREE(netdev_name);
|
|
||||||
}
|
}
|
||||||
virErrorRestore(&originalError);
|
virErrorRestore(&originalError);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -1556,7 +1536,7 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|||||||
{ .hostdev = hostdev } };
|
{ .hostdev = hostdev } };
|
||||||
virDomainDeviceInfoPtr info = hostdev->info;
|
virDomainDeviceInfoPtr info = hostdev->info;
|
||||||
int ret;
|
int ret;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
bool releaseaddr = false;
|
bool releaseaddr = false;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
@ -1658,8 +1638,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
vm->def->hostdevs[vm->def->nhostdevs++] = hostdev;
|
||||||
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -1679,8 +1657,6 @@ qemuDomainAttachHostPCIDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);
|
qemuHostdevReAttachPCIDevices(driver, vm->def->name, &hostdev, 1);
|
||||||
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1726,7 +1702,7 @@ qemuDomainAddTLSObjects(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virErrorPtr orig_err;
|
virErrorPtr orig_err;
|
||||||
char *secAlias = NULL;
|
VIR_AUTOFREE(char *) secAlias = NULL;
|
||||||
|
|
||||||
if (!tlsProps && !secProps)
|
if (!tlsProps && !secProps)
|
||||||
return 0;
|
return 0;
|
||||||
@ -1742,8 +1718,6 @@ qemuDomainAddTLSObjects(virQEMUDriverPtr driver,
|
|||||||
qemuMonitorAddObject(priv->mon, tlsProps, NULL) < 0)
|
qemuMonitorAddObject(priv->mon, tlsProps, NULL) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
VIR_FREE(secAlias);
|
|
||||||
|
|
||||||
return qemuDomainObjExitMonitor(driver, vm);
|
return qemuDomainObjExitMonitor(driver, vm);
|
||||||
|
|
||||||
error:
|
error:
|
||||||
@ -1751,7 +1725,6 @@ qemuDomainAddTLSObjects(virQEMUDriverPtr driver,
|
|||||||
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
ignore_value(qemuDomainObjExitMonitor(driver, vm));
|
||||||
virErrorRestore(&orig_err);
|
virErrorRestore(&orig_err);
|
||||||
qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, NULL);
|
qemuDomainDelTLSObjects(driver, vm, asyncJob, secAlias, NULL);
|
||||||
VIR_FREE(secAlias);
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -1850,20 +1823,18 @@ qemuDomainDelChardevTLSObjects(virQEMUDriverPtr driver,
|
|||||||
virDomainChrSourceDefPtr dev,
|
virDomainChrSourceDefPtr dev,
|
||||||
const char *inAlias)
|
const char *inAlias)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
|
||||||
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *tlsAlias = NULL;
|
VIR_AUTOFREE(char *) tlsAlias = NULL;
|
||||||
char *secAlias = NULL;
|
VIR_AUTOFREE(char *) secAlias = NULL;
|
||||||
|
|
||||||
if (dev->type != VIR_DOMAIN_CHR_TYPE_TCP ||
|
if (dev->type != VIR_DOMAIN_CHR_TYPE_TCP ||
|
||||||
dev->data.tcp.haveTLS != VIR_TRISTATE_BOOL_YES) {
|
dev->data.tcp.haveTLS != VIR_TRISTATE_BOOL_YES) {
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(tlsAlias = qemuAliasTLSObjFromSrcAlias(inAlias)))
|
if (!(tlsAlias = qemuAliasTLSObjFromSrcAlias(inAlias)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* Best shot at this as the secinfo is destroyed after process launch
|
/* Best shot at this as the secinfo is destroyed after process launch
|
||||||
* and this path does not recreate it. Thus, if the config has the
|
* and this path does not recreate it. Thus, if the config has the
|
||||||
@ -1871,7 +1842,7 @@ qemuDomainDelChardevTLSObjects(virQEMUDriverPtr driver,
|
|||||||
* secAlias which we'll attempt to destroy. */
|
* secAlias which we'll attempt to destroy. */
|
||||||
if (cfg->chardevTLSx509secretUUID &&
|
if (cfg->chardevTLSx509secretUUID &&
|
||||||
!(secAlias = qemuDomainGetSecretAESAlias(inAlias, false)))
|
!(secAlias = qemuDomainGetSecretAESAlias(inAlias, false)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
@ -1880,14 +1851,9 @@ qemuDomainDelChardevTLSObjects(virQEMUDriverPtr driver,
|
|||||||
ignore_value(qemuMonitorDelObject(priv->mon, secAlias));
|
ignore_value(qemuMonitorDelObject(priv->mon, secAlias));
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(tlsAlias);
|
|
||||||
VIR_FREE(secAlias);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1898,10 +1864,10 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainDefPtr def = vm->def;
|
virDomainDefPtr def = vm->def;
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *) charAlias = NULL;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
bool chardevAdded = false;
|
bool chardevAdded = false;
|
||||||
char *tlsAlias = NULL;
|
VIR_AUTOFREE(char *) tlsAlias = NULL;
|
||||||
const char *secAlias = NULL;
|
const char *secAlias = NULL;
|
||||||
bool need_release = false;
|
bool need_release = false;
|
||||||
virErrorPtr orig_err;
|
virErrorPtr orig_err;
|
||||||
@ -1948,9 +1914,6 @@ int qemuDomainAttachRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (ret < 0 && need_release)
|
if (ret < 0 && need_release)
|
||||||
qemuDomainReleaseDeviceAddress(vm, &redirdev->info);
|
qemuDomainReleaseDeviceAddress(vm, &redirdev->info);
|
||||||
VIR_FREE(tlsAlias);
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
@ -2134,14 +2097,14 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virErrorPtr orig_err;
|
virErrorPtr orig_err;
|
||||||
virDomainDefPtr vmdef = vm->def;
|
virDomainDefPtr vmdef = vm->def;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
virDomainChrSourceDefPtr dev = chr->source;
|
virDomainChrSourceDefPtr dev = chr->source;
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *)charAlias = NULL;
|
||||||
bool chardevAttached = false;
|
bool chardevAttached = false;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
bool teardowndevice = false;
|
bool teardowndevice = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
char *tlsAlias = NULL;
|
VIR_AUTOFREE(char *) tlsAlias = NULL;
|
||||||
const char *secAlias = NULL;
|
const char *secAlias = NULL;
|
||||||
bool need_release = false;
|
bool need_release = false;
|
||||||
bool guestfwd = false;
|
bool guestfwd = false;
|
||||||
@ -2222,9 +2185,6 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
|
|||||||
if (teardowndevice && qemuDomainNamespaceTeardownChardev(vm, chr) < 0)
|
if (teardowndevice && qemuDomainNamespaceTeardownChardev(vm, chr) < 0)
|
||||||
VIR_WARN("Unable to remove chr device from /dev");
|
VIR_WARN("Unable to remove chr device from /dev");
|
||||||
}
|
}
|
||||||
VIR_FREE(tlsAlias);
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
@ -2249,10 +2209,10 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_RNG, { .rng = rng } };
|
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_RNG, { .rng = rng } };
|
||||||
virErrorPtr orig_err;
|
virErrorPtr orig_err;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *) charAlias = NULL;
|
||||||
char *objAlias = NULL;
|
VIR_AUTOFREE(char *) objAlias = NULL;
|
||||||
char *tlsAlias = NULL;
|
VIR_AUTOFREE(char *) tlsAlias = NULL;
|
||||||
const char *secAlias = NULL;
|
const char *secAlias = NULL;
|
||||||
bool releaseaddr = false;
|
bool releaseaddr = false;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
@ -2338,10 +2298,6 @@ qemuDomainAttachRNGDevice(virQEMUDriverPtr driver,
|
|||||||
VIR_WARN("Unable to remove chr device from /dev");
|
VIR_WARN("Unable to remove chr device from /dev");
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(tlsAlias);
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
VIR_FREE(objAlias);
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
@ -2380,8 +2336,8 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|||||||
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
||||||
unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
|
unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
|
||||||
unsigned long long newmem = oldmem + mem->size;
|
unsigned long long newmem = oldmem + mem->size;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
char *objalias = NULL;
|
VIR_AUTOFREE(char *) objalias = NULL;
|
||||||
bool objAdded = false;
|
bool objAdded = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
@ -2478,8 +2434,6 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
virJSONValueFree(props);
|
virJSONValueFree(props);
|
||||||
VIR_FREE(devstr);
|
|
||||||
VIR_FREE(objalias);
|
|
||||||
virDomainMemoryDefFree(mem);
|
virDomainMemoryDefFree(mem);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -2518,7 +2472,7 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevDefPtr hostdev)
|
virDomainHostdevDefPtr hostdev)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
bool added = false;
|
bool added = false;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
@ -2580,7 +2534,6 @@ qemuDomainAttachHostUSBDevice(virQEMUDriverPtr driver,
|
|||||||
qemuHostdevReAttachUSBDevices(driver, vm->def->name, &hostdev, 1);
|
qemuHostdevReAttachUSBDevices(driver, vm->def->name, &hostdev, 1);
|
||||||
virDomainUSBAddressRelease(priv->usbaddrs, hostdev->info);
|
virDomainUSBAddressRelease(priv->usbaddrs, hostdev->info);
|
||||||
}
|
}
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2594,10 +2547,10 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virErrorPtr orig_err;
|
virErrorPtr orig_err;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
char *drvstr = NULL;
|
VIR_AUTOFREE(char *) drvstr = NULL;
|
||||||
char *drivealias = NULL;
|
VIR_AUTOFREE(char *) drivealias = NULL;
|
||||||
char *secobjAlias = NULL;
|
VIR_AUTOFREE(char *) secobjAlias = NULL;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
bool teardowndevice = false;
|
bool teardowndevice = false;
|
||||||
@ -2699,10 +2652,6 @@ qemuDomainAttachHostSCSIDevice(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
qemuDomainSecretHostdevDestroy(hostdev);
|
qemuDomainSecretHostdevDestroy(hostdev);
|
||||||
virJSONValueFree(secobjProps);
|
virJSONValueFree(secobjProps);
|
||||||
VIR_FREE(secobjAlias);
|
|
||||||
VIR_FREE(drivealias);
|
|
||||||
VIR_FREE(drvstr);
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
@ -2732,9 +2681,9 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_HOSTDEV,
|
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_HOSTDEV,
|
||||||
{ .hostdev = hostdev } };
|
{ .hostdev = hostdev } };
|
||||||
virDomainCCWAddressSetPtr ccwaddrs = NULL;
|
virDomainCCWAddressSetPtr ccwaddrs = NULL;
|
||||||
char *vhostfdName = NULL;
|
VIR_AUTOFREE(char *) vhostfdName = NULL;
|
||||||
int vhostfd = -1;
|
int vhostfd = -1;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
bool teardowndevice = false;
|
bool teardowndevice = false;
|
||||||
@ -2830,8 +2779,6 @@ qemuDomainAttachSCSIVHostDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainCCWAddressSetFree(ccwaddrs);
|
virDomainCCWAddressSetFree(ccwaddrs);
|
||||||
|
|
||||||
VIR_FORCE_CLOSE(vhostfd);
|
VIR_FORCE_CLOSE(vhostfd);
|
||||||
VIR_FREE(vhostfdName);
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2842,7 +2789,7 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevDefPtr hostdev)
|
virDomainHostdevDefPtr hostdev)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
bool added = false;
|
bool added = false;
|
||||||
bool teardowncgroup = false;
|
bool teardowncgroup = false;
|
||||||
bool teardownlabel = false;
|
bool teardownlabel = false;
|
||||||
@ -2927,7 +2874,6 @@ qemuDomainAttachMediatedDevice(virQEMUDriverPtr driver,
|
|||||||
1);
|
1);
|
||||||
qemuDomainReleaseDeviceAddress(vm, hostdev->info);
|
qemuDomainReleaseDeviceAddress(vm, hostdev->info);
|
||||||
}
|
}
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2992,9 +2938,9 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainShmemDefPtr shmem)
|
virDomainShmemDefPtr shmem)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *shmstr = NULL;
|
VIR_AUTOFREE(char *) shmstr = NULL;
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *) charAlias = NULL;
|
||||||
char *memAlias = NULL;
|
VIR_AUTOFREE(char *) memAlias = NULL;
|
||||||
bool release_backing = false;
|
bool release_backing = false;
|
||||||
bool release_address = true;
|
bool release_address = true;
|
||||||
virErrorPtr orig_err = NULL;
|
virErrorPtr orig_err = NULL;
|
||||||
@ -3083,9 +3029,6 @@ qemuDomainAttachShmemDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainReleaseDeviceAddress(vm, &shmem->info);
|
qemuDomainReleaseDeviceAddress(vm, &shmem->info);
|
||||||
|
|
||||||
virJSONValueFree(props);
|
virJSONValueFree(props);
|
||||||
VIR_FREE(memAlias);
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
VIR_FREE(shmstr);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@ -3117,7 +3060,7 @@ qemuDomainAttachWatchdog(virQEMUDriverPtr driver,
|
|||||||
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } };
|
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_WATCHDOG, { .watchdog = watchdog } };
|
||||||
virDomainWatchdogAction actualAction = watchdog->action;
|
virDomainWatchdogAction actualAction = watchdog->action;
|
||||||
const char *actionStr = NULL;
|
const char *actionStr = NULL;
|
||||||
char *watchdogstr = NULL;
|
VIR_AUTOFREE(char *) watchdogstr = NULL;
|
||||||
bool releaseAddress = false;
|
bool releaseAddress = false;
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
@ -3174,7 +3117,6 @@ qemuDomainAttachWatchdog(virQEMUDriverPtr driver,
|
|||||||
cleanup:
|
cleanup:
|
||||||
if (releaseAddress)
|
if (releaseAddress)
|
||||||
qemuDomainReleaseDeviceAddress(vm, &watchdog->info);
|
qemuDomainReleaseDeviceAddress(vm, &watchdog->info);
|
||||||
VIR_FREE(watchdogstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3185,7 +3127,7 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainInputDefPtr input)
|
virDomainInputDefPtr input)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT,
|
virDomainDeviceDef dev = { VIR_DOMAIN_DEVICE_INPUT,
|
||||||
{ .input = input } };
|
{ .input = input } };
|
||||||
@ -3269,7 +3211,6 @@ qemuDomainAttachInputDevice(virQEMUDriverPtr driver,
|
|||||||
virErrorRestore(&originalError);
|
virErrorRestore(&originalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
@ -3293,8 +3234,8 @@ qemuDomainAttachVsockDevice(virQEMUDriverPtr driver,
|
|||||||
virErrorPtr originalError = NULL;
|
virErrorPtr originalError = NULL;
|
||||||
const char *fdprefix = "vsockfd";
|
const char *fdprefix = "vsockfd";
|
||||||
bool releaseaddr = false;
|
bool releaseaddr = false;
|
||||||
char *fdname = NULL;
|
VIR_AUTOFREE(char *) fdname = NULL;
|
||||||
char *devstr = NULL;
|
VIR_AUTOFREE(char *) devstr = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (vm->def->vsock) {
|
if (vm->def->vsock) {
|
||||||
@ -3345,8 +3286,6 @@ qemuDomainAttachVsockDevice(virQEMUDriverPtr driver,
|
|||||||
virErrorRestore(&originalError);
|
virErrorRestore(&originalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_FREE(devstr);
|
|
||||||
VIR_FREE(fdname);
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
exit_monitor:
|
exit_monitor:
|
||||||
@ -4026,22 +3965,21 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
const char *expire;
|
const char *expire;
|
||||||
char *validTo = NULL;
|
VIR_AUTOFREE(char *) validTo = NULL;
|
||||||
const char *connected = NULL;
|
const char *connected = NULL;
|
||||||
const char *password;
|
const char *password;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (!auth->passwd && !defaultPasswd) {
|
if (!auth->passwd && !defaultPasswd)
|
||||||
ret = 0;
|
return 0;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
password = auth->passwd ? auth->passwd : defaultPasswd;
|
password = auth->passwd ? auth->passwd : defaultPasswd;
|
||||||
|
|
||||||
if (auth->connected)
|
if (auth->connected)
|
||||||
connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected);
|
connected = virDomainGraphicsAuthConnectedTypeToString(auth->connected);
|
||||||
|
|
||||||
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
|
||||||
goto cleanup;
|
return ret;
|
||||||
ret = qemuMonitorSetPassword(priv->mon, type, password, connected);
|
ret = qemuMonitorSetPassword(priv->mon, type, password, connected);
|
||||||
|
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
@ -4063,8 +4001,7 @@ qemuDomainChangeGraphicsPasswords(virQEMUDriverPtr driver,
|
|||||||
end_job:
|
end_job:
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(validTo);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4402,7 +4339,7 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
|
unsigned long long oldmem = virDomainDefGetMemoryTotal(vm->def);
|
||||||
unsigned long long newmem = oldmem - mem->size;
|
unsigned long long newmem = oldmem - mem->size;
|
||||||
char *backendAlias = NULL;
|
VIR_AUTOFREE(char *) backendAlias = NULL;
|
||||||
int rc;
|
int rc;
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
@ -4417,8 +4354,6 @@ qemuDomainRemoveMemoryDevice(virQEMUDriverPtr driver,
|
|||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
rc = -1;
|
rc = -1;
|
||||||
|
|
||||||
VIR_FREE(backendAlias);
|
|
||||||
|
|
||||||
virDomainAuditMemory(vm, oldmem, newmem, "update", rc == 0);
|
virDomainAuditMemory(vm, oldmem, newmem, "update", rc == 0);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -4502,10 +4437,9 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
virDomainNetDefPtr net = NULL;
|
virDomainNetDefPtr net = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *drivealias = NULL;
|
VIR_AUTOFREE(char *) drivealias = NULL;
|
||||||
char *objAlias = NULL;
|
VIR_AUTOFREE(char *) objAlias = NULL;
|
||||||
bool is_vfio = false;
|
bool is_vfio = false;
|
||||||
|
|
||||||
VIR_DEBUG("Removing host device %s from domain %p %s",
|
VIR_DEBUG("Removing host device %s from domain %p %s",
|
||||||
@ -4521,7 +4455,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
|
||||||
|
|
||||||
if (!(drivealias = qemuAliasFromHostdev(hostdev)))
|
if (!(drivealias = qemuAliasFromHostdev(hostdev)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
/* Look for the markers that the iSCSI hostdev was added with a
|
/* Look for the markers that the iSCSI hostdev was added with a
|
||||||
* secret object to manage the username/password. If present, let's
|
* secret object to manage the username/password. If present, let's
|
||||||
@ -4530,7 +4464,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|||||||
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET) &&
|
virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET) &&
|
||||||
qemuDomainStorageSourceHasAuth(iscsisrc->src)) {
|
qemuDomainStorageSourceHasAuth(iscsisrc->src)) {
|
||||||
if (!(objAlias = qemuDomainGetSecretAESAlias(hostdev->info->alias, false)))
|
if (!(objAlias = qemuDomainGetSecretAESAlias(hostdev->info->alias, false)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
@ -4541,7 +4475,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|||||||
ignore_value(qemuMonitorDelObject(priv->mon, objAlias));
|
ignore_value(qemuMonitorDelObject(priv->mon, objAlias));
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hostdev->parentnet) {
|
if (hostdev->parentnet) {
|
||||||
@ -4612,12 +4546,7 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainNetDefFree(net);
|
virDomainNetDefFree(net);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(drivealias);
|
|
||||||
VIR_FREE(objAlias);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4628,17 +4557,15 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|||||||
{
|
{
|
||||||
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *hostnet_name = NULL;
|
VIR_AUTOFREE(char *) hostnet_name = NULL;
|
||||||
char *charDevAlias = NULL;
|
VIR_AUTOFREE(char *) charDevAlias = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret = -1;
|
|
||||||
int actualType = virDomainNetGetActualType(net);
|
int actualType = virDomainNetGetActualType(net);
|
||||||
|
|
||||||
if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
|
if (actualType == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
|
||||||
/* this function handles all hostdev and netdev cleanup */
|
/* this function handles all hostdev and netdev cleanup */
|
||||||
ret = qemuDomainRemoveHostDevice(driver, vm,
|
return qemuDomainRemoveHostDevice(driver, vm,
|
||||||
virDomainNetGetActualHostdev(net));
|
virDomainNetGetActualHostdev(net));
|
||||||
goto cleanup;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VIR_DEBUG("Removing network interface %s from domain %p %s",
|
VIR_DEBUG("Removing network interface %s from domain %p %s",
|
||||||
@ -4646,7 +4573,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0 ||
|
if (virAsprintf(&hostnet_name, "host%s", net->info.alias) < 0 ||
|
||||||
!(charDevAlias = qemuAliasChardevFromDevAlias(net->info.alias)))
|
!(charDevAlias = qemuAliasChardevFromDevAlias(net->info.alias)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (virDomainNetGetActualBandwidth(net) &&
|
if (virDomainNetGetActualBandwidth(net) &&
|
||||||
virNetDevSupportBandwidth(virDomainNetGetActualType(net)) &&
|
virNetDevSupportBandwidth(virDomainNetGetActualType(net)) &&
|
||||||
@ -4663,9 +4590,9 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
|
if (qemuMonitorRemoveNetdev(priv->mon, hostnet_name) < 0) {
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
virDomainAuditNet(vm, net, NULL, "detach", false);
|
virDomainAuditNet(vm, net, NULL, "detach", false);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
|
if (actualType == VIR_DOMAIN_NET_TYPE_VHOSTUSER) {
|
||||||
@ -4679,7 +4606,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp)
|
if (QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp)
|
||||||
qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver, net, true);
|
qemuSlirpStop(QEMU_DOMAIN_NETWORK_PRIVATE(net)->slirp, vm, driver, net, true);
|
||||||
@ -4723,12 +4650,7 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
virDomainNetDefFree(net);
|
virDomainNetDefFree(net);
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(charDevAlias);
|
|
||||||
VIR_FREE(hostnet_name);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4739,32 +4661,31 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
|||||||
bool monitor)
|
bool monitor)
|
||||||
{
|
{
|
||||||
virObjectEventPtr event;
|
virObjectEventPtr event;
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *) charAlias = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
int ret = -1;
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
VIR_DEBUG("Removing character device %s from domain %p %s",
|
VIR_DEBUG("Removing character device %s from domain %p %s",
|
||||||
chr->info.alias, vm, vm->def->name);
|
chr->info.alias, vm, vm->def->name);
|
||||||
|
|
||||||
if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
|
if (!(charAlias = qemuAliasChardevFromDevAlias(chr->info.alias)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (monitor) {
|
if (monitor) {
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
|
rc = qemuMonitorDetachCharDev(priv->mon, charAlias);
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rc == 0 &&
|
if (rc == 0 &&
|
||||||
qemuDomainDelChardevTLSObjects(driver, vm, chr->source, charAlias) < 0)
|
qemuDomainDelChardevTLSObjects(driver, vm, chr->source, charAlias) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virDomainAuditChardev(vm, chr, NULL, "detach", rc == 0);
|
virDomainAuditChardev(vm, chr, NULL, "detach", rc == 0);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuTeardownChardevCgroup(vm, chr) < 0)
|
if (qemuTeardownChardevCgroup(vm, chr) < 0)
|
||||||
VIR_WARN("Failed to remove chr device cgroup ACL");
|
VIR_WARN("Failed to remove chr device cgroup ACL");
|
||||||
@ -4786,11 +4707,7 @@ qemuDomainRemoveChrDevice(virQEMUDriverPtr driver,
|
|||||||
virObjectEventStateQueue(driver->domainEventState, event);
|
virObjectEventStateQueue(driver->domainEventState, event);
|
||||||
|
|
||||||
virDomainChrDefFree(chr);
|
virDomainChrDefFree(chr);
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4799,11 +4716,10 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainObjPtr vm,
|
virDomainObjPtr vm,
|
||||||
virDomainRNGDefPtr rng)
|
virDomainRNGDefPtr rng)
|
||||||
{
|
{
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *) charAlias = NULL;
|
||||||
char *objAlias = NULL;
|
VIR_AUTOFREE(char *) objAlias = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
ssize_t idx;
|
ssize_t idx;
|
||||||
int ret = -1;
|
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
VIR_DEBUG("Removing RNG device %s from domain %p %s",
|
VIR_DEBUG("Removing RNG device %s from domain %p %s",
|
||||||
@ -4811,10 +4727,10 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
|
|||||||
|
|
||||||
|
|
||||||
if (virAsprintf(&objAlias, "obj%s", rng->info.alias) < 0)
|
if (virAsprintf(&objAlias, "obj%s", rng->info.alias) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (!(charAlias = qemuAliasChardevFromDevAlias(rng->info.alias)))
|
if (!(charAlias = qemuAliasChardevFromDevAlias(rng->info.alias)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
|
|
||||||
@ -4828,7 +4744,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
|
|||||||
rc = -1;
|
rc = -1;
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD &&
|
if (rng->backend == VIR_DOMAIN_RNG_BACKEND_EGD &&
|
||||||
rc == 0 &&
|
rc == 0 &&
|
||||||
@ -4839,7 +4755,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainAuditRNG(vm, rng, NULL, "detach", rc == 0);
|
virDomainAuditRNG(vm, rng, NULL, "detach", rc == 0);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuTeardownRNGCgroup(vm, rng) < 0)
|
if (qemuTeardownRNGCgroup(vm, rng) < 0)
|
||||||
VIR_WARN("Failed to remove RNG device cgroup ACL");
|
VIR_WARN("Failed to remove RNG device cgroup ACL");
|
||||||
@ -4851,12 +4767,7 @@ qemuDomainRemoveRNGDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainRNGRemove(vm->def, idx);
|
virDomainRNGRemove(vm->def, idx);
|
||||||
qemuDomainReleaseDeviceAddress(vm, &rng->info);
|
qemuDomainReleaseDeviceAddress(vm, &rng->info);
|
||||||
virDomainRNGDefFree(rng);
|
virDomainRNGDefFree(rng);
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
VIR_FREE(objAlias);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4866,10 +4777,9 @@ qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainShmemDefPtr shmem)
|
virDomainShmemDefPtr shmem)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int ret = -1;
|
|
||||||
ssize_t idx = -1;
|
ssize_t idx = -1;
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *) charAlias = NULL;
|
||||||
char *memAlias = NULL;
|
VIR_AUTOFREE(char *) memAlias = NULL;
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
|
|
||||||
VIR_DEBUG("Removing shmem device %s from domain %p %s",
|
VIR_DEBUG("Removing shmem device %s from domain %p %s",
|
||||||
@ -4891,24 +4801,19 @@ qemuDomainRemoveShmemDevice(virQEMUDriverPtr driver,
|
|||||||
rc = qemuMonitorDelObject(priv->mon, memAlias);
|
rc = qemuMonitorDelObject(priv->mon, memAlias);
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virDomainAuditShmem(vm, shmem, "detach", rc == 0);
|
virDomainAuditShmem(vm, shmem, "detach", rc == 0);
|
||||||
|
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if ((idx = virDomainShmemDefFind(vm->def, shmem)) >= 0)
|
if ((idx = virDomainShmemDefFind(vm->def, shmem)) >= 0)
|
||||||
virDomainShmemDefRemove(vm->def, idx);
|
virDomainShmemDefRemove(vm->def, idx);
|
||||||
qemuDomainReleaseDeviceAddress(vm, &shmem->info);
|
qemuDomainReleaseDeviceAddress(vm, &shmem->info);
|
||||||
virDomainShmemDefFree(shmem);
|
virDomainShmemDefFree(shmem);
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
cleanup:
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
VIR_FREE(memAlias);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -4975,15 +4880,14 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
virDomainRedirdevDefPtr dev)
|
virDomainRedirdevDefPtr dev)
|
||||||
{
|
{
|
||||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||||
char *charAlias = NULL;
|
VIR_AUTOFREE(char *) charAlias = NULL;
|
||||||
ssize_t idx;
|
ssize_t idx;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
VIR_DEBUG("Removing redirdev device %s from domain %p %s",
|
VIR_DEBUG("Removing redirdev device %s from domain %p %s",
|
||||||
dev->info.alias, vm, vm->def->name);
|
dev->info.alias, vm, vm->def->name);
|
||||||
|
|
||||||
if (!(charAlias = qemuAliasChardevFromDevAlias(dev->info.alias)))
|
if (!(charAlias = qemuAliasChardevFromDevAlias(dev->info.alias)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
qemuDomainObjEnterMonitor(driver, vm);
|
qemuDomainObjEnterMonitor(driver, vm);
|
||||||
/* DeviceDel from Detach may remove chardev,
|
/* DeviceDel from Detach may remove chardev,
|
||||||
@ -4992,10 +4896,10 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
|
ignore_value(qemuMonitorDetachCharDev(priv->mon, charAlias));
|
||||||
|
|
||||||
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
if (qemuDomainObjExitMonitor(driver, vm) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuDomainDelChardevTLSObjects(driver, vm, dev->source, charAlias) < 0)
|
if (qemuDomainDelChardevTLSObjects(driver, vm, dev->source, charAlias) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
virDomainAuditRedirdev(vm, dev, "detach", true);
|
virDomainAuditRedirdev(vm, dev, "detach", true);
|
||||||
|
|
||||||
@ -5004,11 +4908,7 @@ qemuDomainRemoveRedirdevDevice(virQEMUDriverPtr driver,
|
|||||||
qemuDomainReleaseDeviceAddress(vm, &dev->info);
|
qemuDomainReleaseDeviceAddress(vm, &dev->info);
|
||||||
virDomainRedirdevDefFree(dev);
|
virDomainRedirdevDefFree(dev);
|
||||||
|
|
||||||
ret = 0;
|
return 0;
|
||||||
|
|
||||||
cleanup:
|
|
||||||
VIR_FREE(charAlias);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user