mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Add support for attach/detach/update hostdev devices in config for LXC
Wire up the attach/detach/update device APIs to support changing of hostdevs in the persistent config file Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
8cacd8b4ea
commit
986c270dac
@ -2928,6 +2928,7 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
int ret = -1;
|
||||
virDomainDiskDefPtr disk;
|
||||
virDomainNetDefPtr net;
|
||||
virDomainHostdevDefPtr hostdev;
|
||||
|
||||
switch (dev->type) {
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
@ -2956,6 +2957,21 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
hostdev = dev->data.hostdev;
|
||||
if (virDomainHostdevFind(vmdef, hostdev, NULL) >= 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("device is already in the domain configuration"));
|
||||
return -1;
|
||||
}
|
||||
if (virDomainHostdevInsert(vmdef, hostdev) < 0) {
|
||||
virReportOOMError();
|
||||
return -1;
|
||||
}
|
||||
dev->data.hostdev = NULL;
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("persistent attach of device is not supported"));
|
||||
@ -3017,6 +3033,7 @@ lxcDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
||||
int ret = -1;
|
||||
virDomainDiskDefPtr disk, det_disk;
|
||||
virDomainNetDefPtr net;
|
||||
virDomainHostdevDefPtr hostdev, det_hostdev;
|
||||
int idx;
|
||||
char mac[VIR_MAC_STRING_BUFLEN];
|
||||
|
||||
@ -3050,6 +3067,19 @@ lxcDomainDetachDeviceConfig(virDomainDefPtr vmdef,
|
||||
ret = 0;
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV: {
|
||||
hostdev = dev->data.hostdev;
|
||||
if ((idx = virDomainHostdevFind(vmdef, hostdev, &det_hostdev)) < 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
_("device not present in domain configuration"));
|
||||
return -1;
|
||||
}
|
||||
virDomainHostdevRemove(vmdef, idx);
|
||||
virDomainHostdevDefFree(det_hostdev);
|
||||
ret = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("persistent detach of device is not supported"));
|
||||
|
Loading…
x
Reference in New Issue
Block a user