提交 986c270d 编写于 作者: D Daniel P. Berrange

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: NDaniel P. Berrange <berrange@redhat.com>
上级 8cacd8b4
...@@ -2928,6 +2928,7 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef, ...@@ -2928,6 +2928,7 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
int ret = -1; int ret = -1;
virDomainDiskDefPtr disk; virDomainDiskDefPtr disk;
virDomainNetDefPtr net; virDomainNetDefPtr net;
virDomainHostdevDefPtr hostdev;
switch (dev->type) { switch (dev->type) {
case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_DISK:
...@@ -2956,6 +2957,21 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef, ...@@ -2956,6 +2957,21 @@ lxcDomainAttachDeviceConfig(virDomainDefPtr vmdef,
ret = 0; ret = 0;
break; 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: default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("persistent attach of device is not supported")); _("persistent attach of device is not supported"));
...@@ -3017,6 +3033,7 @@ lxcDomainDetachDeviceConfig(virDomainDefPtr vmdef, ...@@ -3017,6 +3033,7 @@ lxcDomainDetachDeviceConfig(virDomainDefPtr vmdef,
int ret = -1; int ret = -1;
virDomainDiskDefPtr disk, det_disk; virDomainDiskDefPtr disk, det_disk;
virDomainNetDefPtr net; virDomainNetDefPtr net;
virDomainHostdevDefPtr hostdev, det_hostdev;
int idx; int idx;
char mac[VIR_MAC_STRING_BUFLEN]; char mac[VIR_MAC_STRING_BUFLEN];
...@@ -3050,6 +3067,19 @@ lxcDomainDetachDeviceConfig(virDomainDefPtr vmdef, ...@@ -3050,6 +3067,19 @@ lxcDomainDetachDeviceConfig(virDomainDefPtr vmdef,
ret = 0; ret = 0;
break; 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: default:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("persistent detach of device is not supported")); _("persistent detach of device is not supported"));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册