On 10/20/2015 11:38 AM, Luyao Huang wrote:
https://bugzilla.redhat.com/show_bug.cgi?id=1238338#c6
If the user already specify address in xml, we will set the
wrong $fromConfig, which will make libvirt output a wrong error
message and make hot-plug fail when hot-plug a pci device (see
commit 1e15be1 and 9a12b6c).
Signed-off-by: Luyao Huang <lhuang(a)redhat.com>
---
src/conf/domain_addr.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
Self NACK, although there is a small problem with the error message, but
commit 1e15be1 and 9a12b6c not want skip the check during hot-plug a pci
device to a not support hot-plug bus on a q35 machine, so this patch
will introduce a another issue.
BTW, from the c033e210613b860bef4859a81e22088d0d2f0f29, we could know that
""
the same error message will be changed to indicate
either "internal" or "xml" error depending on whether the address
came
from the config, or was automatically generated by libvirt
""
so in this place i hot-plug a device which specified the address in xml,
i should get error VIR_ERR_XML_ERROR. however i got an internal error.
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index ca5803e..49769f7 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -376,6 +376,14 @@ virDomainPCIAddressReserveSlot(virDomainPCIAddressSetPtr addrs,
return virDomainPCIAddressReserveAddr(addrs, addr, flags, true, false);
}
+static int
+virDomainPCIAddressReserveSlotFromConfig(virDomainPCIAddressSetPtr addrs,
+ virDevicePCIAddressPtr addr,
+ virDomainPCIConnectFlags flags)
+{
+ return virDomainPCIAddressReserveAddr(addrs, addr, flags, true, true);
+}
+
int
virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
virDomainDeviceInfoPtr dev)
@@ -408,7 +416,8 @@ virDomainPCIAddressEnsureAddr(virDomainPCIAddressSetPtr addrs,
addrStr, flags, true))
goto cleanup;
- ret = virDomainPCIAddressReserveSlot(addrs, &dev->addr.pci, flags);
+ ret = virDomainPCIAddressReserveSlotFromConfig(addrs,
+ &dev->addr.pci, flags);
} else {
ret = virDomainPCIAddressReserveNextSlot(addrs, dev, flags);
}