mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 06:05:27 +00:00
Introduce virDomainVirtioSerialAddrAutoAssign again
This time do not require an address cache as a parameter.
Simplify qemuDomainAttachChrDeviceAssignAddr to not generate
the virtio serial address cache for devices of other types.
Partially reverts commit 925fa4b
.
This commit is contained in:
parent
0512dd26ee
commit
ac518960a6
@ -1201,6 +1201,27 @@ virDomainVirtioSerialAddrAutoAssignFromCache(virDomainDefPtr def,
|
||||
return virDomainVirtioSerialAddrAssign(def, addrs, info, allowZero, portOnly);
|
||||
}
|
||||
|
||||
int
|
||||
virDomainVirtioSerialAddrAutoAssign(virDomainDefPtr def,
|
||||
virDomainDeviceInfoPtr info,
|
||||
bool allowZero)
|
||||
{
|
||||
virDomainVirtioSerialAddrSetPtr addrs = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (!(addrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
|
||||
goto cleanup;
|
||||
|
||||
if (virDomainVirtioSerialAddrAutoAssignFromCache(def, addrs, info, allowZero) < 0)
|
||||
goto cleanup;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virDomainVirtioSerialAddrSetFree(addrs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
|
||||
|
@ -230,6 +230,12 @@ virDomainVirtioSerialAddrAutoAssignFromCache(virDomainDefPtr def,
|
||||
bool allowZero)
|
||||
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
||||
|
||||
int
|
||||
virDomainVirtioSerialAddrAutoAssign(virDomainDefPtr def,
|
||||
virDomainDeviceInfoPtr info,
|
||||
bool allowZero)
|
||||
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
||||
|
||||
int
|
||||
virDomainVirtioSerialAddrAssign(virDomainDefPtr def,
|
||||
virDomainVirtioSerialAddrSetPtr addrs,
|
||||
|
@ -123,6 +123,7 @@ virDomainUSBAddressSetAddHub;
|
||||
virDomainUSBAddressSetCreate;
|
||||
virDomainUSBAddressSetFree;
|
||||
virDomainVirtioSerialAddrAssign;
|
||||
virDomainVirtioSerialAddrAutoAssign;
|
||||
virDomainVirtioSerialAddrAutoAssignFromCache;
|
||||
virDomainVirtioSerialAddrIsComplete;
|
||||
virDomainVirtioSerialAddrRelease;
|
||||
|
@ -1763,15 +1763,10 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObjPtr vm,
|
||||
virDomainDefPtr def = vm->def;
|
||||
qemuDomainObjPrivatePtr priv = vm->privateData;
|
||||
int ret = -1;
|
||||
virDomainVirtioSerialAddrSetPtr vioaddrs = NULL;
|
||||
|
||||
if (!(vioaddrs = virDomainVirtioSerialAddrSetCreateFromDomain(def)))
|
||||
goto cleanup;
|
||||
|
||||
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
|
||||
chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
|
||||
if (virDomainVirtioSerialAddrAutoAssignFromCache(NULL, vioaddrs,
|
||||
&chr->info, true) < 0)
|
||||
if (virDomainVirtioSerialAddrAutoAssign(def, &chr->info, true) < 0)
|
||||
goto cleanup;
|
||||
ret = 1;
|
||||
|
||||
@ -1789,8 +1784,7 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObjPtr vm,
|
||||
|
||||
} else if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL &&
|
||||
chr->targetType == VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO) {
|
||||
if (virDomainVirtioSerialAddrAutoAssignFromCache(NULL, vioaddrs,
|
||||
&chr->info, false) < 0)
|
||||
if (virDomainVirtioSerialAddrAutoAssign(def, &chr->info, false) < 0)
|
||||
goto cleanup;
|
||||
ret = 1;
|
||||
}
|
||||
@ -1808,7 +1802,6 @@ qemuDomainAttachChrDeviceAssignAddr(virDomainObjPtr vm,
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virDomainVirtioSerialAddrSetFree(vioaddrs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user