mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemu: Fix error code when attaching existing device
An attempt to attach device that is already attached to a domain results in the following error: virsh # attach-device rhel6 pci2 --persistent error: Failed to attach device from pci2 error: invalid argument: device is already in the domain configuration The "invalid argument" error code looks wrong, we usually use "operation invalid" when the action cannot be done in current state.
This commit is contained in:
parent
2edbd3d918
commit
935550c6d3
@ -6299,8 +6299,8 @@ qemuDomainAttachDeviceConfig(qemuCapsPtr caps,
|
||||
case VIR_DOMAIN_DEVICE_DISK:
|
||||
disk = dev->data.disk;
|
||||
if (virDomainDiskIndexByName(vmdef, disk->dst, true) >= 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
_("target %s already exists."), disk->dst);
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("target %s already exists"), disk->dst);
|
||||
return -1;
|
||||
}
|
||||
if (virDomainDiskInsert(vmdef, disk)) {
|
||||
@ -6330,7 +6330,7 @@ qemuDomainAttachDeviceConfig(qemuCapsPtr caps,
|
||||
case VIR_DOMAIN_DEVICE_HOSTDEV:
|
||||
hostdev = dev->data.hostdev;
|
||||
if (virDomainHostdevFind(vmdef, hostdev, NULL) >= 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("device is already in the domain configuration"));
|
||||
return -1;
|
||||
}
|
||||
@ -6346,7 +6346,7 @@ qemuDomainAttachDeviceConfig(qemuCapsPtr caps,
|
||||
case VIR_DOMAIN_DEVICE_LEASE:
|
||||
lease = dev->data.lease;
|
||||
if (virDomainLeaseIndex(vmdef, lease) >= 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG,
|
||||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("Lease %s in lockspace %s already exists"),
|
||||
lease->key, NULLSTR(lease->lockspace));
|
||||
return -1;
|
||||
@ -6362,7 +6362,7 @@ qemuDomainAttachDeviceConfig(qemuCapsPtr caps,
|
||||
controller = dev->data.controller;
|
||||
if (virDomainControllerFind(vmdef, controller->type,
|
||||
controller->idx) > 0) {
|
||||
virReportError(VIR_ERR_INVALID_ARG, "%s",
|
||||
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
|
||||
_("Target already exists"));
|
||||
return -1;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user