2010/10/22 Daniel P. Berrange <berrange@xxxxxxxxxx>: > On Fri, Oct 22, 2010 at 02:23:15PM +0200, Matthias Bolte wrote: >> --- >> Âsrc/vbox/vbox_tmpl.c | Â116 +++++++++++++++++++++++++++++++++++++++++++------- >> Â1 files changed, 100 insertions(+), 16 deletions(-) >> >> diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c >> index 5a859a4..ddbca97 100644 >> --- a/src/vbox/vbox_tmpl.c >> +++ b/src/vbox/vbox_tmpl.c >> @@ -626,6 +626,45 @@ static PRUnichar *PRUnicharFromInt(int n) { >> >> Â#endif /* !(VBOX_API_VERSION == 2002) */ >> >> +static PRUnichar * >> +vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) >> +{ >> + Â Âchar *utf8 = NULL; >> + Â ÂPRUnichar *utf16 = NULL; >> + >> + Â Âutf8 = virSocketFormatAddr(addr); >> + >> + Â Âif (utf8 == NULL) { >> + Â Â Â Âreturn NULL; >> + Â Â} >> + >> + Â ÂVBOX_UTF8_TO_UTF16(utf8, &utf16); >> + Â ÂVIR_FREE(utf8); >> + >> + Â Âreturn utf16; >> +} >> + >> +static int >> +vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â virSocketAddrPtr addr) >> +{ >> + Â Âint result = -1; >> + Â Âchar *utf8 = NULL; >> + >> + Â ÂVBOX_UTF16_TO_UTF8(utf16, &utf8); >> + >> + Â Âif (virSocketParseAddr(utf8, addr, AF_UNSPEC) < 0) { >> + Â Â Â Âgoto cleanup; >> + Â Â} >> + >> + Â Âresult = 0; >> + >> +cleanup: >> + Â ÂVBOX_UTF8_FREE(utf8); >> + >> + Â Âreturn result; >> +} >> + >> Âstatic virCapsPtr vboxCapsInit(void) { >> Â Â Âstruct utsname utsname; >> Â Â ÂvirCapsPtr caps; >> @@ -7073,8 +7112,8 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char * >> Â Â Â Â Â * with contigious address space from start to end >> Â Â Â Â Â */ >> Â Â Â Â Âif ((def->nranges >= 1) && >> - Â Â Â Â Â Â(def->ranges[0].start) && >> - Â Â Â Â Â Â(def->ranges[0].end)) { >> + Â Â Â Â Â ÂVIR_SOCKET_HAS_ADDR(&def->ranges[0].start) && >> + Â Â Â Â Â ÂVIR_SOCKET_HAS_ADDR(&def->ranges[0].end)) { >> Â Â Â Â Â Â ÂIDHCPServer *dhcpServer = NULL; >> >> Â Â Â Â Â Â Âdata->vboxObj->vtbl->FindDHCPServerByNetworkName(data->vboxObj, >> @@ -7094,11 +7133,21 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char * >> Â Â Â Â Â Â Â Â ÂPRUnichar *toIPAddressUtf16 Â = NULL; >> Â Â Â Â Â Â Â Â ÂPRUnichar *trunkTypeUtf16 Â Â = NULL; >> >> + Â Â Â Â Â Â Â ÂipAddressUtf16 = vboxSocketFormatAddrUtf16(data, &def->ipAddress); >> + Â Â Â Â Â Â Â ÂnetworkMaskUtf16 = vboxSocketFormatAddrUtf16(data, &def->netmask); >> + Â Â Â Â Â Â Â ÂfromIPAddressUtf16 = vboxSocketFormatAddrUtf16(data, &def->ranges[0].start); >> + Â Â Â Â Â Â Â ÂtoIPAddressUtf16 = vboxSocketFormatAddrUtf16(data, &def->ranges[0].end); >> + >> + Â Â Â Â Â Â Â Âif (ipAddressUtf16 == NULL || networkMaskUtf16 == NULL || >> + Â Â Â Â Â Â Â Â Â ÂfromIPAddressUtf16 == NULL || toIPAddressUtf16 == NULL) { >> + Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(ipAddressUtf16); >> + Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(networkMaskUtf16); >> + Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(fromIPAddressUtf16); >> + Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(toIPAddressUtf16); >> + Â Â Â Â Â Â Â Â Â ÂVBOX_RELEASE(dhcpServer); >> + Â Â Â Â Â Â Â Â Â Âgoto cleanup; >> + Â Â Â Â Â Â Â Â} >> >> - Â Â Â Â Â Â Â ÂVBOX_UTF8_TO_UTF16(def->ipAddress, &ipAddressUtf16); >> - Â Â Â Â Â Â Â ÂVBOX_UTF8_TO_UTF16(def->netmask, &networkMaskUtf16); >> - Â Â Â Â Â Â Â ÂVBOX_UTF8_TO_UTF16(def->ranges[0].start, &fromIPAddressUtf16); >> - Â Â Â Â Â Â Â ÂVBOX_UTF8_TO_UTF16(def->ranges[0].end, &toIPAddressUtf16); >> Â Â Â Â Â Â Â Â ÂVBOX_UTF8_TO_UTF16("netflt", &trunkTypeUtf16); >> >> Â Â Â Â Â Â Â Â ÂdhcpServer->vtbl->SetEnabled(dhcpServer, PR_TRUE); >> @@ -7125,12 +7174,18 @@ static virNetworkPtr vboxNetworkDefineCreateXML(virConnectPtr conn, const char * >> Â Â Â Â Â} >> >> Â Â Â Â Âif ((def->nhosts >= 1) && >> - Â Â Â Â Â Â(def->hosts[0].ip)) { >> + Â Â Â Â Â ÂVIR_SOCKET_HAS_ADDR(&def->hosts[0].ip)) { >> Â Â Â Â Â Â ÂPRUnichar *ipAddressUtf16 Â = NULL; >> Â Â Â Â Â Â ÂPRUnichar *networkMaskUtf16 = NULL; >> >> - Â Â Â Â Â ÂVBOX_UTF8_TO_UTF16(def->netmask, &networkMaskUtf16); >> - Â Â Â Â Â ÂVBOX_UTF8_TO_UTF16(def->hosts[0].ip, &ipAddressUtf16); >> + Â Â Â Â Â ÂipAddressUtf16 = vboxSocketFormatAddrUtf16(data, &def->hosts[0].ip); >> + Â Â Â Â Â ÂnetworkMaskUtf16 = vboxSocketFormatAddrUtf16(data, &def->netmask); >> + >> + Â Â Â Â Â Âif (ipAddressUtf16 == NULL || networkMaskUtf16 == NULL) { >> + Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(ipAddressUtf16); >> + Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(networkMaskUtf16); >> + Â Â Â Â Â Â Â Âgoto cleanup; >> + Â Â Â Â Â Â} >> >> Â Â Â Â Â Â Â/* Current drawback is that since EnableStaticIpConfig() sets >> Â Â Â Â Â Â Â * IP and enables the interface so even if the dhcpserver is not >> @@ -7393,6 +7448,7 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE >> Â Â Â Â Â Â Â Â Â Â Â Â ÂPRUnichar *networkMaskUtf16 Â = NULL; >> Â Â Â Â Â Â Â Â Â Â Â Â ÂPRUnichar *fromIPAddressUtf16 = NULL; >> Â Â Â Â Â Â Â Â Â Â Â Â ÂPRUnichar *toIPAddressUtf16 Â = NULL; >> + Â Â Â Â Â Â Â Â Â Â Â Âbool errorOccurred = false; >> >> Â Â Â Â Â Â Â Â Â Â Â Â ÂdhcpServer->vtbl->GetIPAddress(dhcpServer, &ipAddressUtf16); >> Â Â Â Â Â Â Â Â Â Â Â Â ÂdhcpServer->vtbl->GetNetworkMask(dhcpServer, &networkMaskUtf16); >> @@ -7401,15 +7457,25 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE >> Â Â Â Â Â Â Â Â Â Â Â Â Â/* Currently virtualbox supports only one dhcp server per network >> Â Â Â Â Â Â Â Â Â Â Â Â Â * with contigious address space from start to end >> Â Â Â Â Â Â Â Â Â Â Â Â Â */ >> - Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(ipAddressUtf16, &def->ipAddress); >> - Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(networkMaskUtf16, &def->netmask); >> - Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(fromIPAddressUtf16, &def->ranges[0].start); >> - Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(toIPAddressUtf16, &def->ranges[0].end); >> + Â Â Â Â Â Â Â Â Â Â Â Âif (vboxSocketParseAddrUtf16(data, ipAddressUtf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &def->ipAddress) < 0 || >> + Â Â Â Â Â Â Â Â Â Â Â Â Â ÂvboxSocketParseAddrUtf16(data, networkMaskUtf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &def->netmask) < 0 || >> + Â Â Â Â Â Â Â Â Â Â Â Â Â ÂvboxSocketParseAddrUtf16(data, fromIPAddressUtf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &def->ranges[0].start) < 0 || >> + Â Â Â Â Â Â Â Â Â Â Â Â Â ÂvboxSocketParseAddrUtf16(data, toIPAddressUtf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &def->ranges[0].end) < 0) { >> + Â Â Â Â Â Â Â Â Â Â Â Â Â ÂerrorOccurred = true; >> + Â Â Â Â Â Â Â Â Â Â Â Â} >> >> Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(ipAddressUtf16); >> Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(networkMaskUtf16); >> Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(fromIPAddressUtf16); >> Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(toIPAddressUtf16); >> + >> + Â Â Â Â Â Â Â Â Â Â Â Âif (errorOccurred) { >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Âgoto cleanup; >> + Â Â Â Â Â Â Â Â Â Â Â Â} >> Â Â Â Â Â Â Â Â Â Â Â} else { >> Â Â Â Â Â Â Â Â Â Â Â Â Âdef->nranges = 0; >> Â Â Â Â Â Â Â Â Â Â Â Â ÂvirReportOOMError(); >> @@ -7425,15 +7491,24 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE >> Â Â Â Â Â Â Â Â Â Â Â Â Â} else { >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂPRUnichar *macAddressUtf16 = NULL; >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂPRUnichar *ipAddressUtf16 Â= NULL; >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Âbool errorOccurred = false; >> >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂnetworkInterface->vtbl->GetHardwareAddress(networkInterface, &macAddressUtf16); >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂnetworkInterface->vtbl->GetIPAddress(networkInterface, &ipAddressUtf16); >> >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(macAddressUtf16, &def->hosts[0].mac); >> - Â Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(ipAddressUtf16, &def->hosts[0].ip); >> + >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Âif (vboxSocketParseAddrUtf16(data, ipAddressUtf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &def->hosts[0].ip) < 0) { >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂerrorOccurred = true; >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â} >> >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(macAddressUtf16); >> Â Â Â Â Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(ipAddressUtf16); >> + >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Âif (errorOccurred) { >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âgoto cleanup; >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â} >> Â Â Â Â Â Â Â Â Â Â Â Â Â} >> Â Â Â Â Â Â Â Â Â Â Â} else { >> Â Â Â Â Â Â Â Â Â Â Â Â Âdef->nhosts = 0; >> @@ -7443,15 +7518,24 @@ static char *vboxNetworkDumpXML(virNetworkPtr network, int flags ATTRIBUTE_UNUSE >> Â Â Â Â Â Â Â Â Â} else { >> Â Â Â Â Â Â Â Â Â Â ÂPRUnichar *networkMaskUtf16 = NULL; >> Â Â Â Â Â Â Â Â Â Â ÂPRUnichar *ipAddressUtf16 Â = NULL; >> + Â Â Â Â Â Â Â Â Â Âbool errorOccurred = false; >> >> Â Â Â Â Â Â Â Â Â Â ÂnetworkInterface->vtbl->GetNetworkMask(networkInterface, &networkMaskUtf16); >> Â Â Â Â Â Â Â Â Â Â ÂnetworkInterface->vtbl->GetIPAddress(networkInterface, &ipAddressUtf16); >> >> - Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(networkMaskUtf16, &def->netmask); >> - Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_TO_UTF8(ipAddressUtf16, &def->ipAddress); >> + Â Â Â Â Â Â Â Â Â Âif (vboxSocketParseAddrUtf16(data, networkMaskUtf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &def->netmask) < 0 || >> + Â Â Â Â Â Â Â Â Â Â Â ÂvboxSocketParseAddrUtf16(data, ipAddressUtf16, >> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â &def->ipAddress) < 0) { >> + Â Â Â Â Â Â Â Â Â Â Â ÂerrorOccurred = true; >> + Â Â Â Â Â Â Â Â Â Â} >> >> Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(networkMaskUtf16); >> Â Â Â Â Â Â Â Â Â Â ÂVBOX_UTF16_FREE(ipAddressUtf16); >> + >> + Â Â Â Â Â Â Â Â Â Âif (errorOccurred) { >> + Â Â Â Â Â Â Â Â Â Â Â Âgoto cleanup; >> + Â Â Â Â Â Â Â Â Â Â} >> Â Â Â Â Â Â Â Â Â} >> >> Â Â Â Â Â Â Â Â ÂDEBUGIID("Network UUID", vboxnet0IID); > > ACK. Thanks, pushed. > This highlights a problem caused by a changeset df90ca7661b0a789bd790ccf8258a4527c13eb8d > > Previously the vbox driver would be compiled by default, and any check > for the XPCOM was at runtime. Now the configure.ac script disables > vbox at build time, if it can't find the XPCOM. This is not good since > it means that if the main OS distro repositories don't contain VBox > libvirt won't get support compiled in. This then prevents a user > obtaining vbox from a 3rd party & using libvirt with it. > > IMHO we should revert this changeset so we do the check at runtime > again, and simply have a configure flag that lets the user specify > extra paths to be checked at runtime. > > Regards, > Daniel > I think you're right. The changeset df90ca7661 addresses this bug report https://bugzilla.redhat.com/show_bug.cgi?id=609185, but also removed the runtime lookup for the XPCOM lib. I'll provide a patch that improves this. Matthias -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list