提交 89e991a2 编写于 作者: J Ján Tomko

Assign an address when hotplugging a virtio-serial device

上级 ee0d97a7
...@@ -1541,6 +1541,8 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, ...@@ -1541,6 +1541,8 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
virDomainDefPtr vmdef = vm->def; virDomainDefPtr vmdef = vm->def;
char *devstr = NULL; char *devstr = NULL;
char *charAlias = NULL; char *charAlias = NULL;
bool need_release = false;
bool allowZero = false;
if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) { if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE)) {
virReportError(VIR_ERR_OPERATION_INVALID, "%s", virReportError(VIR_ERR_OPERATION_INVALID, "%s",
...@@ -1551,6 +1553,16 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, ...@@ -1551,6 +1553,16 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0) if (qemuAssignDeviceChrAlias(vmdef, chr, -1) < 0)
goto cleanup; goto cleanup;
if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO)
allowZero = true;
if (virDomainVirtioSerialAddrAutoAssign(priv->vioserialaddrs,
&chr->info,
allowZero) < 0)
goto cleanup;
need_release = true;
if (qemuBuildChrDeviceStr(&devstr, vm->def, chr, priv->qemuCaps) < 0) if (qemuBuildChrDeviceStr(&devstr, vm->def, chr, priv->qemuCaps) < 0)
goto cleanup; goto cleanup;
...@@ -1582,6 +1594,8 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver, ...@@ -1582,6 +1594,8 @@ int qemuDomainAttachChrDevice(virQEMUDriverPtr driver,
cleanup: cleanup:
if (ret < 0 && virDomainObjIsActive(vm)) if (ret < 0 && virDomainObjIsActive(vm))
qemuDomainChrInsertPreAllocCleanup(vm->def, chr); qemuDomainChrInsertPreAllocCleanup(vm->def, chr);
if (ret < 0 && need_release)
virDomainVirtioSerialAddrRelease(priv->vioserialaddrs, &chr->info);
VIR_FREE(charAlias); VIR_FREE(charAlias);
VIR_FREE(devstr); VIR_FREE(devstr);
return ret; return ret;
...@@ -4120,10 +4134,13 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver, ...@@ -4120,10 +4134,13 @@ int qemuDomainDetachChrDevice(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
rc = qemuDomainWaitForDeviceRemoval(vm); rc = qemuDomainWaitForDeviceRemoval(vm);
if (rc == 0 || rc == 1) if (rc == 0 || rc == 1) {
virDomainVirtioSerialAddrRelease(priv->vioserialaddrs, &tmpChr->info);
ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr); ret = qemuDomainRemoveChrDevice(driver, vm, tmpChr);
else } else {
ret = 0; ret = 0;
}
cleanup: cleanup:
qemuDomainResetDeviceRemoval(vm); qemuDomainResetDeviceRemoval(vm);
......
...@@ -86,7 +86,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt, ...@@ -86,7 +86,7 @@ qemuHotplugCreateObjects(virDomainXMLOptionPtr xmlopt,
if (event) if (event)
virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT); virQEMUCapsSet(priv->qemuCaps, QEMU_CAPS_DEVICE_DEL_EVENT);
if (qemuDomainAssignPCIAddresses((*vm)->def, priv->qemuCaps, *vm) < 0) if (qemuDomainAssignAddresses((*vm)->def, priv->qemuCaps, *vm) < 0)
goto cleanup; goto cleanup;
if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0) if (qemuAssignDeviceAliases((*vm)->def, priv->qemuCaps) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册