[libvirt] libvirt 0.7.5 vs qemu 0.12.1 imcompatability?
by Tom Hughes
The update from qemu 0.11.0 to qemu 0.12.1 in the virt-preview
repository seems to have broken things. Starting a VM now just gives me
a blank screen and a log which says:
Option 'ipv4': Use 'on' or 'off'
Failed to parse "yes" for "dummy.ipv4"
I assume libvirt is sending a it a command on the monitor interface that
it no longer understands...
Tom
--
Tom Hughes (tom(a)compton.nu)
http://www.compton.nu/
14 years, 9 months
[libvirt] [PATCH] virsh: Use VIR_FREE instead of free
by Matthias Bolte
virsh uses other parts of the internal API already, so use VIR_FREE also.
---
tools/virsh.c | 297 ++++++++++++++++++++++++++++-----------------------------
1 files changed, 146 insertions(+), 151 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index e2a32b4..2844927 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -46,6 +46,7 @@
#include "buf.h"
#include "console.h"
#include "util.h"
+#include "memory.h"
static char *progname;
@@ -481,7 +482,7 @@ cmdConnect(vshControl *ctl, const vshCmd *cmd)
ctl->conn = NULL;
}
- free(ctl->name);
+ VIR_FREE(ctl->name);
ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL));
if (!ro) {
@@ -560,7 +561,7 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom)
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOWARNING);
- free(doc);
+ VIR_FREE(doc);
if (!xml)
goto cleanup;
ctxt = xmlXPathNewContext(xml);
@@ -583,8 +584,8 @@ cmdRunConsole(vshControl *ctl, virDomainPtr dom)
xmlXPathFreeContext(ctxt);
if (xml)
xmlFreeDoc(xml);
- free(thisHost);
- free(thatHost);
+ VIR_FREE(thisHost);
+ VIR_FREE(thatHost);
return ret;
}
@@ -651,7 +652,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxid = virConnectListDomains(ctl->conn, &ids[0], maxid)) < 0) {
vshError(ctl, "%s", _("Failed to list active domains"));
- free(ids);
+ VIR_FREE(ids);
return FALSE;
}
@@ -662,7 +663,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxname = virConnectNumOfDefinedDomains(ctl->conn);
if (maxname < 0) {
vshError(ctl, "%s", _("Failed to list inactive domains"));
- free(ids);
+ VIR_FREE(ids);
return FALSE;
}
if (maxname) {
@@ -670,8 +671,8 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) {
vshError(ctl, "%s", _("Failed to list inactive domains"));
- free(ids);
- free(names);
+ VIR_FREE(ids);
+ VIR_FREE(names);
return FALSE;
}
@@ -708,7 +709,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with domains is not atomic operation */
if (!dom) {
- free(names[i]);
+ VIR_FREE(names[i]);
continue;
}
@@ -720,10 +721,10 @@ cmdList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, "%3s %-20s %s\n", "-", names[i], state);
virDomainFree(dom);
- free(names[i]);
+ VIR_FREE(names[i]);
}
- free(ids);
- free(names);
+ VIR_FREE(ids);
+ VIR_FREE(names);
return TRUE;
}
@@ -1019,7 +1020,7 @@ cmdCreate(vshControl *ctl, const vshCmd *cmd)
return FALSE;
dom = virDomainCreateXML(ctl->conn, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
if (dom != NULL) {
vshPrint(ctl, _("Domain %s created from %s\n"),
@@ -1070,7 +1071,7 @@ cmdDefine(vshControl *ctl, const vshCmd *cmd)
return FALSE;
dom = virDomainDefineXML(ctl->conn, buffer);
- free (buffer);
+ VIR_FREE(buffer);
if (dom != NULL) {
vshPrint(ctl, _("Domain %s defined from %s\n"),
@@ -1371,7 +1372,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
if (schedulertype!= NULL){
vshPrint(ctl, "%-15s: %s\n", _("Scheduler"),
schedulertype);
- free(schedulertype);
+ VIR_FREE(schedulertype);
} else {
vshPrint(ctl, "%-15s: %s\n", _("Scheduler"), _("Unknown"));
goto cleanup;
@@ -1436,7 +1437,7 @@ cmdSchedinfo(vshControl *ctl, const vshCmd *cmd)
}
cleanup:
- free(params);
+ VIR_FREE(params);
virDomainFree(dom);
return ret_val;
}
@@ -1724,7 +1725,7 @@ cmdDominfo(vshControl *ctl, const vshCmd *cmd)
if ((str = virDomainGetOSType(dom))) {
vshPrint(ctl, "%-15s %s\n", _("OS Type:"), str);
- free(str);
+ VIR_FREE(str);
}
if (virDomainGetInfo(dom, &info) == 0) {
@@ -1912,8 +1913,8 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd)
ret = FALSE;
}
- free(cpumap);
- free(cpuinfo);
+ VIR_FREE(cpumap);
+ VIR_FREE(cpuinfo);
virDomainFree(dom);
return ret;
}
@@ -2037,7 +2038,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
VIR_USE_CPU(cpumap, cpu);
} else {
vshError(ctl, _("Physical CPU %d doesn't exist."), cpu);
- free(cpumap);
+ VIR_FREE(cpumap);
virDomainFree(dom);
return FALSE;
}
@@ -2050,7 +2051,7 @@ cmdVcpupin(vshControl *ctl, const vshCmd *cmd)
ret = FALSE;
}
- free(cpumap);
+ VIR_FREE(cpumap);
virDomainFree(dom);
return ret;
}
@@ -2281,7 +2282,7 @@ cmdCapabilities (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
return FALSE;
}
vshPrint (ctl, "%s\n", caps);
- free (caps);
+ VIR_FREE(caps);
return TRUE;
}
@@ -2326,7 +2327,7 @@ cmdDumpXML(vshControl *ctl, const vshCmd *cmd)
dump = virDomainGetXMLDesc(dom, flags);
if (dump != NULL) {
printf("%s", dump);
- free(dump);
+ VIR_FREE(dump);
} else {
ret = FALSE;
}
@@ -2373,7 +2374,7 @@ cmdDomXMLFromNative(vshControl *ctl, const vshCmd *cmd)
xmlData = virConnectDomainXMLFromNative(ctl->conn, format, configData, flags);
if (xmlData != NULL) {
printf("%s", xmlData);
- free(xmlData);
+ VIR_FREE(xmlData);
} else {
ret = FALSE;
}
@@ -2419,7 +2420,7 @@ cmdDomXMLToNative(vshControl *ctl, const vshCmd *cmd)
configData = virConnectDomainXMLToNative(ctl->conn, format, xmlData, flags);
if (configData != NULL) {
printf("%s", configData);
- free(configData);
+ VIR_FREE(configData);
} else {
ret = FALSE;
}
@@ -2707,7 +2708,7 @@ cmdNetworkCreate(vshControl *ctl, const vshCmd *cmd)
return FALSE;
network = virNetworkCreateXML(ctl->conn, buffer);
- free (buffer);
+ VIR_FREE(buffer);
if (network != NULL) {
vshPrint(ctl, _("Network %s created from %s\n"),
@@ -2755,7 +2756,7 @@ cmdNetworkDefine(vshControl *ctl, const vshCmd *cmd)
return FALSE;
network = virNetworkDefineXML(ctl->conn, buffer);
- free (buffer);
+ VIR_FREE(buffer);
if (network != NULL) {
vshPrint(ctl, _("Network %s defined from %s\n"),
@@ -2838,7 +2839,7 @@ cmdNetworkDumpXML(vshControl *ctl, const vshCmd *cmd)
dump = virNetworkGetXMLDesc(network, 0);
if (dump != NULL) {
printf("%s", dump);
- free(dump);
+ VIR_FREE(dump);
} else {
ret = FALSE;
}
@@ -2936,13 +2937,13 @@ cleanup:
if (iface)
virInterfaceFree (iface);
- free (doc);
- free (doc_edited);
- free (doc_reread);
+ VIR_FREE(doc);
+ VIR_FREE(doc_edited);
+ VIR_FREE(doc_reread);
if (tmp) {
unlink (tmp);
- free (tmp);
+ VIR_FREE(tmp);
}
return ret;
@@ -2988,7 +2989,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxactive = virConnectListNetworks(ctl->conn, activeNames,
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active networks"));
- free(activeNames);
+ VIR_FREE(activeNames);
return FALSE;
}
@@ -2999,7 +3000,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxinactive = virConnectNumOfDefinedNetworks(ctl->conn);
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive networks"));
- free(activeNames);
+ VIR_FREE(activeNames);
return FALSE;
}
if (maxinactive) {
@@ -3009,8 +3010,8 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
virConnectListDefinedNetworks(ctl->conn, inactiveNames,
maxinactive)) < 0) {
vshError(ctl, "%s", _("Failed to list inactive networks"));
- free(activeNames);
- free(inactiveNames);
+ VIR_FREE(activeNames);
+ VIR_FREE(inactiveNames);
return FALSE;
}
@@ -3029,7 +3030,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with networks is not atomic operation */
if (!network) {
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
continue;
}
@@ -3043,7 +3044,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
_("active"),
autostartStr);
virNetworkFree(network);
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
}
for (i = 0; i < maxinactive; i++) {
virNetworkPtr network = virNetworkLookupByName(ctl->conn, inactiveNames[i]);
@@ -3052,7 +3053,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with networks is not atomic operation */
if (!network) {
- free(inactiveNames[i]);
+ VIR_FREE(inactiveNames[i]);
continue;
}
@@ -3067,10 +3068,10 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
autostartStr);
virNetworkFree(network);
- free(inactiveNames[i]);
+ VIR_FREE(inactiveNames[i]);
}
- free(activeNames);
- free(inactiveNames);
+ VIR_FREE(activeNames);
+ VIR_FREE(inactiveNames);
return TRUE;
}
@@ -3261,7 +3262,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxactive = virConnectListInterfaces(ctl->conn, activeNames,
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active interfaces"));
- free(activeNames);
+ VIR_FREE(activeNames);
return FALSE;
}
@@ -3272,7 +3273,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxinactive = virConnectNumOfDefinedInterfaces(ctl->conn);
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
- free(activeNames);
+ VIR_FREE(activeNames);
return FALSE;
}
if (maxinactive) {
@@ -3282,8 +3283,8 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
virConnectListDefinedInterfaces(ctl->conn, inactiveNames,
maxinactive)) < 0) {
vshError(ctl, "%s", _("Failed to list inactive interfaces"));
- free(activeNames);
- free(inactiveNames);
+ VIR_FREE(activeNames);
+ VIR_FREE(inactiveNames);
return FALSE;
}
@@ -3300,7 +3301,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with interfaces is not atomic */
if (!iface) {
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
continue;
}
@@ -3309,7 +3310,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
_("active"),
virInterfaceGetMACString(iface));
virInterfaceFree(iface);
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
}
for (i = 0; i < maxinactive; i++) {
virInterfacePtr iface =
@@ -3317,7 +3318,7 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with interfaces is not atomic */
if (!iface) {
- free(inactiveNames[i]);
+ VIR_FREE(inactiveNames[i]);
continue;
}
@@ -3326,10 +3327,10 @@ cmdInterfaceList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
_("inactive"),
virInterfaceGetMACString(iface));
virInterfaceFree(iface);
- free(inactiveNames[i]);
+ VIR_FREE(inactiveNames[i]);
}
- free(activeNames);
- free(inactiveNames);
+ VIR_FREE(activeNames);
+ VIR_FREE(inactiveNames);
return TRUE;
}
@@ -3430,7 +3431,7 @@ cmdInterfaceDumpXML(vshControl *ctl, const vshCmd *cmd)
dump = virInterfaceGetXMLDesc(iface, flags);
if (dump != NULL) {
printf("%s", dump);
- free(dump);
+ VIR_FREE(dump);
} else {
ret = FALSE;
}
@@ -3473,7 +3474,7 @@ cmdInterfaceDefine(vshControl *ctl, const vshCmd *cmd)
return FALSE;
iface = virInterfaceDefineXML(ctl->conn, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
if (iface != NULL) {
vshPrint(ctl, _("Interface %s defined from %s\n"),
@@ -3685,7 +3686,7 @@ cmdPoolCreate(vshControl *ctl, const vshCmd *cmd)
return FALSE;
pool = virStoragePoolCreateXML(ctl->conn, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
if (pool != NULL) {
vshPrint(ctl, _("Pool %s created from %s\n"),
@@ -3739,7 +3740,7 @@ cmdNodeDeviceCreate(vshControl *ctl, const vshCmd *cmd)
}
dev = virNodeDeviceCreateXML(ctl->conn, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
if (dev != NULL) {
vshPrint(ctl, _("Node device %s created from %s\n"),
@@ -3896,10 +3897,10 @@ cmdPoolCreateAs(vshControl *ctl, const vshCmd *cmd)
if (printXML) {
printf("%s", xml);
- free (xml);
+ VIR_FREE(xml);
} else {
pool = virStoragePoolCreateXML(ctl->conn, xml, 0);
- free (xml);
+ VIR_FREE(xml);
if (pool != NULL) {
vshPrint(ctl, _("Pool %s created\n"), name);
@@ -3947,7 +3948,7 @@ cmdPoolDefine(vshControl *ctl, const vshCmd *cmd)
return FALSE;
pool = virStoragePoolDefineXML(ctl->conn, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
if (pool != NULL) {
vshPrint(ctl, _("Pool %s defined from %s\n"),
@@ -3985,10 +3986,10 @@ cmdPoolDefineAs(vshControl *ctl, const vshCmd *cmd)
if (printXML) {
printf("%s", xml);
- free (xml);
+ VIR_FREE(xml);
} else {
pool = virStoragePoolDefineXML(ctl->conn, xml, 0);
- free (xml);
+ VIR_FREE(xml);
if (pool != NULL) {
vshPrint(ctl, _("Pool %s defined\n"), name);
@@ -4188,7 +4189,7 @@ cmdPoolDumpXML(vshControl *ctl, const vshCmd *cmd)
dump = virStoragePoolGetXMLDesc(pool, 0);
if (dump != NULL) {
printf("%s", dump);
- free(dump);
+ VIR_FREE(dump);
} else {
ret = FALSE;
}
@@ -4238,7 +4239,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxactive = virConnectListStoragePools(ctl->conn, activeNames,
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active pools"));
- free(activeNames);
+ VIR_FREE(activeNames);
return FALSE;
}
@@ -4249,7 +4250,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxinactive = virConnectNumOfDefinedStoragePools(ctl->conn);
if (maxinactive < 0) {
vshError(ctl, "%s", _("Failed to list inactive pools"));
- free(activeNames);
+ VIR_FREE(activeNames);
return FALSE;
}
if (maxinactive) {
@@ -4257,8 +4258,8 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxinactive = virConnectListDefinedStoragePools(ctl->conn, inactiveNames, maxinactive)) < 0) {
vshError(ctl, "%s", _("Failed to list inactive pools"));
- free(activeNames);
- free(inactiveNames);
+ VIR_FREE(activeNames);
+ VIR_FREE(inactiveNames);
return FALSE;
}
@@ -4275,7 +4276,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with pools is not atomic operation */
if (!pool) {
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
continue;
}
@@ -4289,7 +4290,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
_("active"),
autostartStr);
virStoragePoolFree(pool);
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
}
for (i = 0; i < maxinactive; i++) {
virStoragePoolPtr pool = virStoragePoolLookupByName(ctl->conn, inactiveNames[i]);
@@ -4298,7 +4299,7 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with pools is not atomic operation */
if (!pool) {
- free(inactiveNames[i]);
+ VIR_FREE(inactiveNames[i]);
continue;
}
@@ -4313,10 +4314,10 @@ cmdPoolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
autostartStr);
virStoragePoolFree(pool);
- free(inactiveNames[i]);
+ VIR_FREE(inactiveNames[i]);
}
- free(activeNames);
- free(inactiveNames);
+ VIR_FREE(activeNames);
+ VIR_FREE(inactiveNames);
return TRUE;
}
@@ -4388,13 +4389,13 @@ cmdPoolDiscoverSourcesAs(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
}
srcList = virConnectFindStoragePoolSources(ctl->conn, type, srcSpec, 0);
- free(srcSpec);
+ VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
return FALSE;
}
vshPrint(ctl, "%s", srcList);
- free(srcList);
+ VIR_FREE(srcList);
return TRUE;
}
@@ -4439,13 +4440,13 @@ cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED)
return FALSE;
srcList = virConnectFindStoragePoolSources(ctl->conn, type, srcSpec, 0);
- free(srcSpec);
+ VIR_FREE(srcSpec);
if (srcList == NULL) {
vshError(ctl, _("Failed to find any %s pool sources"), type);
return FALSE;
}
vshPrint(ctl, "%s", srcList);
- free(srcList);
+ VIR_FREE(srcList);
return TRUE;
}
@@ -4718,7 +4719,7 @@ cmdVolCreateAs(vshControl *ctl, const vshCmd *cmd)
}
xml = virBufferContentAndReset(&buf);
vol = virStorageVolCreateXML(pool, xml, 0);
- free (xml);
+ VIR_FREE(xml);
virStoragePoolFree(pool);
if (vol != NULL) {
@@ -4857,7 +4858,7 @@ cmdVolCreate(vshControl *ctl, const vshCmd *cmd)
}
vol = virStorageVolCreateXML(pool, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
virStoragePoolFree(pool);
if (vol != NULL) {
@@ -4928,7 +4929,7 @@ cmdVolCreateFrom(vshControl *ctl, const vshCmd *cmd)
ret = TRUE;
cleanup:
- free (buffer);
+ VIR_FREE(buffer);
if (pool)
virStoragePoolFree(pool);
if (inputvol)
@@ -5036,7 +5037,7 @@ cmdVolClone(vshControl *ctl, const vshCmd *cmd)
ret = TRUE;
cleanup:
- free(origxml);
+ VIR_FREE(origxml);
xmlFree(newxml);
if (origvol)
virStorageVolFree(origvol);
@@ -5170,7 +5171,7 @@ cmdVolDumpXML(vshControl *ctl, const vshCmd *cmd)
dump = virStorageVolGetXMLDesc(vol, 0);
if (dump != NULL) {
printf("%s", dump);
- free(dump);
+ VIR_FREE(dump);
} else {
ret = FALSE;
}
@@ -5219,7 +5220,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
if ((maxactive = virStoragePoolListVolumes(pool, activeNames,
maxactive)) < 0) {
vshError(ctl, "%s", _("Failed to list active vols"));
- free(activeNames);
+ VIR_FREE(activeNames);
virStoragePoolFree(pool);
return FALSE;
}
@@ -5235,7 +5236,7 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
/* this kind of work with vols is not atomic operation */
if (!vol) {
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
continue;
}
@@ -5248,11 +5249,11 @@ cmdVolList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
vshPrint(ctl, "%-20s %-40s\n",
virStorageVolGetName(vol),
path);
- free(path);
+ VIR_FREE(path);
virStorageVolFree(vol);
- free(activeNames[i]);
+ VIR_FREE(activeNames[i]);
}
- free(activeNames);
+ VIR_FREE(activeNames);
virStoragePoolFree(pool);
return TRUE;
}
@@ -5390,7 +5391,7 @@ cmdSecretDefine(vshControl *ctl, const vshCmd *cmd)
return FALSE;
res = virSecretDefineXML(ctl->conn, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
if (res == NULL) {
vshError(ctl, _("Failed to set attributes from %s"), from);
@@ -5438,7 +5439,7 @@ cmdSecretDumpXML(vshControl *ctl, const vshCmd *cmd)
if (xml == NULL)
goto cleanup;
printf("%s", xml);
- free(xml);
+ VIR_FREE(xml);
ret = TRUE;
cleanup:
@@ -5491,7 +5492,7 @@ cmdSecretSetValue(vshControl *ctl, const vshCmd *cmd)
res = virSecretSetValue(secret, (unsigned char *)value, value_size, 0);
memset(value, 0, value_size);
- free (value);
+ VIR_FREE(value);
if (res != 0) {
vshError(ctl, "%s", _("Failed to set secret value"));
@@ -5541,7 +5542,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
base64_encode_alloc((char *)value, value_size, &base64);
memset(value, 0, value_size);
- free(value);
+ VIR_FREE(value);
if (base64 == NULL) {
vshError(ctl, "%s", _("Failed to allocate memory"));
@@ -5549,7 +5550,7 @@ cmdSecretGetValue(vshControl *ctl, const vshCmd *cmd)
}
printf("%s", base64);
memset(base64, 0, strlen(base64));
- free(base64);
+ VIR_FREE(base64);
ret = TRUE;
cleanup:
@@ -5625,7 +5626,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
maxuuids = virConnectListSecrets(ctl->conn, uuids, maxuuids);
if (maxuuids < 0) {
vshError(ctl, "%s", _("Failed to list secrets"));
- free(uuids);
+ VIR_FREE(uuids);
return FALSE;
}
@@ -5639,7 +5640,7 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
const char *usageType = NULL;
if (!sec) {
- free(uuids[i]);
+ VIR_FREE(uuids[i]);
continue;
}
@@ -5658,9 +5659,9 @@ cmdSecretList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
uuids[i], _("Unused"));
}
virSecretFree(sec);
- free(uuids[i]);
+ VIR_FREE(uuids[i]);
}
- free(uuids);
+ VIR_FREE(uuids);
return TRUE;
}
@@ -5867,7 +5868,7 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
virNodeListDevices(ctl->conn, cap, devices, num_devices, 0);
if (num_devices < 0) {
vshError(ctl, "%s", _("Failed to list node devices"));
- free(devices);
+ VIR_FREE(devices);
return FALSE;
}
qsort(&devices[0], num_devices, sizeof(char*), namesorter);
@@ -5898,17 +5899,17 @@ cmdNodeListDevices (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
indentBuf);
}
for (i = 0 ; i < num_devices ; i++) {
- free(devices[i]);
- free(parents[i]);
+ VIR_FREE(devices[i]);
+ VIR_FREE(parents[i]);
}
- free(parents);
+ VIR_FREE(parents);
} else {
for (i = 0; i < num_devices; i++) {
vshPrint(ctl, "%s\n", devices[i]);
- free(devices[i]);
+ VIR_FREE(devices[i]);
}
}
- free(devices);
+ VIR_FREE(devices);
return TRUE;
}
@@ -5950,7 +5951,7 @@ cmdNodeDeviceDumpXML (vshControl *ctl, const vshCmd *cmd)
}
vshPrint(ctl, "%s\n", xml);
- free(xml);
+ VIR_FREE(xml);
virNodeDeviceFree(device);
return TRUE;
}
@@ -6102,7 +6103,7 @@ cmdHostname (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
vshPrint (ctl, "%s\n", hostname);
- free (hostname);
+ VIR_FREE(hostname);
return TRUE;
}
@@ -6131,7 +6132,7 @@ cmdURI (vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
}
vshPrint (ctl, "%s\n", uri);
- free (uri);
+ VIR_FREE(uri);
return TRUE;
}
@@ -6174,7 +6175,7 @@ cmdVNCDisplay(vshControl *ctl, const vshCmd *cmd)
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOWARNING);
- free(doc);
+ VIR_FREE(doc);
if (!xml)
goto cleanup;
ctxt = xmlXPathNewContext(xml);
@@ -6248,7 +6249,7 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd)
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOWARNING);
- free(doc);
+ VIR_FREE(doc);
if (!xml)
goto cleanup;
ctxt = xmlXPathNewContext(xml);
@@ -6315,7 +6316,7 @@ cmdAttachDevice(vshControl *ctl, const vshCmd *cmd)
}
ret = virDomainAttachDevice(dom, buffer);
- free (buffer);
+ VIR_FREE(buffer);
if (ret < 0) {
vshError(ctl, _("Failed to attach device from %s"), from);
@@ -6373,7 +6374,7 @@ cmdDetachDevice(vshControl *ctl, const vshCmd *cmd)
}
ret = virDomainDetachDevice(dom, buffer);
- free (buffer);
+ VIR_FREE(buffer);
if (ret < 0) {
vshError(ctl, _("Failed to detach device from %s"), from);
@@ -6499,8 +6500,8 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd)
cleanup:
if (dom)
virDomainFree(dom);
- free(buf);
- free(tmp);
+ VIR_FREE(buf);
+ VIR_FREE(tmp);
return ret;
}
@@ -6552,7 +6553,7 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd)
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOWARNING);
- free(doc);
+ VIR_FREE(doc);
if (!xml) {
vshError(ctl, "%s", _("Failed to get interface information"));
goto cleanup;
@@ -6776,8 +6777,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
cleanup:
if (dom)
virDomainFree(dom);
- free(buf);
- free(tmp);
+ VIR_FREE(buf);
+ VIR_FREE(tmp);
return ret;
}
@@ -6825,7 +6826,7 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd)
xml = xmlReadDoc((const xmlChar *) doc, "domain.xml", NULL,
XML_PARSE_NOENT | XML_PARSE_NONET |
XML_PARSE_NOWARNING);
- free(doc);
+ VIR_FREE(doc);
if (!xml) {
vshError(ctl, "%s", _("Failed to get disk information"));
goto cleanup;
@@ -6927,7 +6928,7 @@ cmdCPUCompare(vshControl *ctl, const vshCmd *cmd)
return FALSE;
result = virConnectCompareCPU(ctl->conn, buffer, 0);
- free (buffer);
+ VIR_FREE(buffer);
switch (result) {
case VIR_CPU_COMPARE_INCOMPATIBLE:
@@ -6979,7 +6980,7 @@ editWriteToTempFile (vshControl *ctl, const char *doc)
if (fd == -1) {
vshError(ctl, _("mkstemp: failed to create temporary file: %s"),
strerror(errno));
- free (ret);
+ VIR_FREE(ret);
return NULL;
}
@@ -6988,14 +6989,14 @@ editWriteToTempFile (vshControl *ctl, const char *doc)
ret, strerror(errno));
close (fd);
unlink (ret);
- free (ret);
+ VIR_FREE(ret);
return NULL;
}
if (close (fd) == -1) {
vshError(ctl, _("close: %s: failed to write or close temporary file: %s"),
ret, strerror(errno));
unlink (ret);
- free (ret);
+ VIR_FREE(ret);
return NULL;
}
@@ -7047,16 +7048,16 @@ editFile (vshControl *ctl, const char *filename)
if (command_ret == -1) {
vshError(ctl,
_("%s: edit command failed: %s"), command, strerror(errno));
- free (command);
+ VIR_FREE(command);
return -1;
}
if (command_ret != WEXITSTATUS (0)) {
vshError(ctl,
_("%s: command exited with non-zero status"), command);
- free (command);
+ VIR_FREE(command);
return -1;
}
- free (command);
+ VIR_FREE(command);
return 0;
}
@@ -7153,7 +7154,7 @@ cmdPwd(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
else
vshPrint (ctl, _("%s\n"), cwd);
- free (cwd);
+ VIR_FREE(cwd);
return !err;
}
#endif
@@ -7249,13 +7250,13 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd)
if (dom)
virDomainFree (dom);
- free (doc);
- free (doc_edited);
- free (doc_reread);
+ VIR_FREE(doc);
+ VIR_FREE(doc_edited);
+ VIR_FREE(doc_reread);
if (tmp) {
unlink (tmp);
- free (tmp);
+ VIR_FREE(tmp);
}
return ret;
@@ -7620,8 +7621,8 @@ vshCommandOptFree(vshCmdOpt * arg)
a = a->next;
- free(tmp->data);
- free(tmp);
+ VIR_FREE(tmp->data);
+ VIR_FREE(tmp);
}
}
@@ -7637,7 +7638,7 @@ vshCommandFree(vshCmd *cmd)
if (tmp->opts)
vshCommandOptFree(tmp->opts);
- free(tmp);
+ VIR_FREE(tmp);
}
}
@@ -7705,7 +7706,7 @@ vshCommandOptStringList(const vshCmd *cmd, const char *name, char ***data)
if (arg->def && STREQ(arg->def->name, name)) {
char **tmp = realloc(val, sizeof(*tmp) * (nval+1));
if (!tmp) {
- free(val);
+ VIR_FREE(val);
return -1;
}
val = tmp;
@@ -8171,8 +8172,7 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
vshError(ctl, _("unknown command: '%s'"), tkdata);
goto syntaxError; /* ... or ignore this command only? */
}
- free(tkdata);
- tkdata = NULL;
+ VIR_FREE(tkdata);
} else if (tk == VSH_TK_OPTION) {
if (!(opt = vshCmddefGetOption(cmd, tkdata))) {
vshError(ctl,
@@ -8180,8 +8180,7 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
cmd->name, tkdata);
goto syntaxError;
}
- free(tkdata); /* option name */
- tkdata = NULL;
+ VIR_FREE(tkdata); /* option name */
if (opt->type != VSH_OT_BOOL) {
/* option data */
@@ -8238,7 +8237,7 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
c->next = NULL;
if (!vshCommandCheckOpts(ctl, c)) {
- free(c);
+ VIR_FREE(c);
goto syntaxError;
}
@@ -8257,7 +8256,7 @@ vshCommandParse(vshControl *ctl, char *cmdstr)
vshCommandFree(ctl->cmd);
if (first)
vshCommandOptFree(first);
- free(tkdata);
+ VIR_FREE(tkdata);
return FALSE;
}
@@ -8398,7 +8397,7 @@ _vshRealloc(vshControl *ctl, void *ptr, size_t size, const char *filename, int l
if ((x = realloc(ptr, size)))
return x;
- free(ptr);
+ VIR_FREE(ptr);
vshError(ctl, _("%s: %d: failed to allocate %d bytes"),
filename, line, (int) size);
exit(EXIT_FAILURE);
@@ -8578,7 +8577,7 @@ vshCloseLogFile(vshControl *ctl)
}
if (ctl->logfile) {
- free(ctl->logfile);
+ VIR_FREE(ctl->logfile);
ctl->logfile = NULL;
}
}
@@ -8644,7 +8643,7 @@ vshReadlineOptionsGenerator(const char *text, int state)
cmd = vshCmddefSearch(cmdname);
list_index = 0;
len = strlen(text);
- free(cmdname);
+ VIR_FREE(cmdname);
}
if (!cmd)
@@ -8714,17 +8713,17 @@ vshReadlineInit(vshControl *ctl)
if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir) < 0) {
vshError(ctl, "%s", _("Out of memory"));
- free(userdir);
+ VIR_FREE(userdir);
return -1;
}
if (virAsprintf(&ctl->historyfile, "%s/histroy", ctl->historydir) < 0) {
vshError(ctl, "%s", _("Out of memory"));
- free(userdir);
+ VIR_FREE(userdir);
return -1;
}
- free(userdir);
+ VIR_FREE(userdir);
read_history(ctl->historyfile);
@@ -8743,11 +8742,8 @@ vshReadlineDeinit (vshControl *ctl)
write_history(ctl->historyfile);
}
- free(ctl->historydir);
- free(ctl->historyfile);
-
- ctl->historydir = NULL;
- ctl->historyfile = NULL;
+ VIR_FREE(ctl->historydir);
+ VIR_FREE(ctl->historyfile);
}
static char *
@@ -8800,7 +8796,7 @@ vshDeinit(vshControl *ctl)
{
vshReadlineDeinit(ctl);
vshCloseLogFile(ctl);
- free(ctl->name);
+ VIR_FREE(ctl->name);
if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) {
vshError(ctl, "%s", _("failed to disconnect from the hypervisor"));
@@ -8964,7 +8960,7 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
vshDebug(ctl, 2, "command: \"%s\"\n", cmdstr);
ret = vshCommandParse(ctl, cmdstr);
- free(cmdstr);
+ VIR_FREE(cmdstr);
return ret;
}
return TRUE;
@@ -9044,8 +9040,7 @@ main(int argc, char **argv)
if (vshCommandParse(ctl, ctl->cmdstr))
vshCommandRun(ctl, ctl->cmd);
}
- free(ctl->cmdstr);
- ctl->cmdstr = NULL;
+ VIR_FREE(ctl->cmdstr);
} while (ctl->imode);
if (ctl->cmdstr == NULL)
--
1.6.0.4
14 years, 9 months
[libvirt] [PATCH] xend_internal: don't let invalid input provoke NULL dereference
by Jim Meyering
If there's a good reason to test for NULL "conn", then
we certainly must not dereference "conn" before that point.
This assumes we do want to retain the NULL test.
Note that many other functions perform this same test.
>From 2c7b628728efcb5a59c1e7aa1cba763f5ef0045a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Wed, 6 Jan 2010 12:59:21 +0100
Subject: [PATCH] xend_internal: don't let invalid input provoke NULL dereference
* src/xen/xend_internal.c (xenDaemonOpen_unix): Do not dereference
a NULL "conn". Move first deref to follow the "conn == NULL" test.
---
src/xen/xend_internal.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 827aac4..be033f5 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -748,11 +748,12 @@ int
xenDaemonOpen_unix(virConnectPtr conn, const char *path)
{
struct sockaddr_un *addr;
- xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
+ xenUnifiedPrivatePtr priv;
if ((conn == NULL) || (path == NULL))
return (-1);
+ priv = (xenUnifiedPrivatePtr) conn->privateData;
memset(&priv->addr, 0, sizeof(priv->addr));
priv->addrfamily = AF_UNIX;
/*
--
1.6.6.387.g2649b1
14 years, 10 months
[libvirt] [PATCH] virsh: Add persistent history using libreadline
by Matthias Bolte
---
tools/virsh.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 65 insertions(+), 4 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 21f9710..e2a32b4 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -41,6 +41,7 @@
#endif
#include "internal.h"
+#include "virterror_internal.h"
#include "base64.h"
#include "buf.h"
#include "console.h"
@@ -197,6 +198,8 @@ typedef struct __vshControl {
*/
char *logfile; /* log file name */
int log_fd; /* log file descriptor */
+ char *historydir; /* readline history directory name */
+ char *historyfile; /* readline history file name */
} __vshControl;
@@ -8689,9 +8692,11 @@ vshReadlineCompletion(const char *text, int start,
}
-static void
-vshReadlineInit(void)
+static int
+vshReadlineInit(vshControl *ctl)
{
+ char *userdir = NULL;
+
/* Allow conditional parsing of the ~/.inputrc file. */
rl_readline_name = "virsh";
@@ -8700,6 +8705,49 @@ vshReadlineInit(void)
/* Limit the total size of the history buffer */
stifle_history(500);
+
+ /* Prepare to read/write history from/to the ~/.virsh/history file */
+ userdir = virGetUserDirectory(NULL, getuid());
+
+ if (userdir == NULL)
+ return -1;
+
+ if (virAsprintf(&ctl->historydir, "%s/.virsh", userdir) < 0) {
+ vshError(ctl, "%s", _("Out of memory"));
+ free(userdir);
+ return -1;
+ }
+
+ if (virAsprintf(&ctl->historyfile, "%s/histroy", ctl->historydir) < 0) {
+ vshError(ctl, "%s", _("Out of memory"));
+ free(userdir);
+ return -1;
+ }
+
+ free(userdir);
+
+ read_history(ctl->historyfile);
+
+ return 0;
+}
+
+static void
+vshReadlineDeinit (vshControl *ctl)
+{
+ if (ctl->historyfile != NULL) {
+ if (mkdir(ctl->historydir, 0755) < 0 && errno != EEXIST) {
+ char ebuf[1024];
+ vshError(ctl, _("Failed to create '%s': %s"),
+ ctl->historydir, virStrerror(errno, ebuf, sizeof ebuf));
+ } else
+ write_history(ctl->historyfile);
+ }
+
+ free(ctl->historydir);
+ free(ctl->historyfile);
+
+ ctl->historydir = NULL;
+ ctl->historyfile = NULL;
}
static char *
@@ -8710,8 +8758,15 @@ vshReadline (vshControl *ctl ATTRIBUTE_UNUSED, const char *prompt)
#else /* !USE_READLINE */
+static int
+vshReadlineInit (vshControl *ctl ATTRIBUTE_UNUSED)
+{
+ /* empty */
+ return 0;
+}
+
static void
-vshReadlineInit (void)
+vshReadlineDeinit (vshControl *ctl ATTRIBUTE_UNUSED)
{
/* empty */
}
@@ -8743,6 +8798,7 @@ vshReadline (vshControl *ctl, const char *prompt)
static int
vshDeinit(vshControl *ctl)
{
+ vshReadlineDeinit(ctl);
vshCloseLogFile(ctl);
free(ctl->name);
if (ctl->conn) {
@@ -8969,7 +9025,12 @@ main(int argc, char **argv)
_("Type: 'help' for help with commands\n"
" 'quit' to quit\n\n"));
}
- vshReadlineInit();
+
+ if (vshReadlineInit(ctl) < 0) {
+ vshDeinit(ctl);
+ exit(EXIT_FAILURE);
+ }
+
do {
const char *prompt = ctl->readonly ? VSH_PROMPT_RO : VSH_PROMPT_RW;
ctl->cmdstr =
--
1.6.0.4
14 years, 10 months
[libvirt] [PATCH] esx: Fix 'vpx' MAC address range and allow arbitrary MAC addresses
by Matthias Bolte
The MAC addresses with 00:50:56 prefix are split into several ranges:
00:50:56:00:00:00 - 00:50:56:3f:ff:ff 'static' range (manually assigned)
00:50:56:80:00:00 - 00:50:56:bf:ff:ff 'vpx' range (assigned by a VI Client)
Erroneously the 'vpx' range was assumed to be larger and to occupy the
remaining addresses of the 00:50:56 prefix that are not part of the 'static'
range.
00:50:56 was used as prefix for generated MAC addresses, this is not possible
anymore, because there are gaps in the allowed ranges. Therefore, change the
prefix to 00:0c:29 which is the prefix for auto generated MAC addresses anyway.
Allow arbitrary MAC addresses to be used and set the checkMACAddress VMX option
to false in case the MAC address doesn't fall into any predefined range.
* docs/drvesx.html.in: update website accordingly
* src/esx/esx_driver.c: set the auto generation prefix to 00:0c:29
* src/esx/esx_vmx.c: fix MAC address range handling and allow arbitrary MAC
addresses
* tests/vmx2xml*, tests/xml2vmx*: add some basic MAC address range tests
---
docs/drvesx.html.in | 74 ++++++++++++++++++++--
src/esx/esx_driver.c | 2 +-
src/esx/esx_vmx.c | 49 +++++++++------
tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx | 8 +++
tests/vmx2xmldata/vmx2xml-ethernet-generated.xml | 19 ++++++
tests/vmx2xmldata/vmx2xml-ethernet-other.vmx | 8 +++
tests/vmx2xmldata/vmx2xml-ethernet-other.xml | 19 ++++++
tests/vmx2xmldata/vmx2xml-ethernet-static.vmx | 7 ++
tests/vmx2xmldata/vmx2xml-ethernet-static.xml | 19 ++++++
tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx | 7 ++
tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml | 19 ++++++
tests/vmx2xmltest.c | 5 ++
tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx | 13 ++++
tests/xml2vmxdata/xml2vmx-ethernet-generated.xml | 14 ++++
tests/xml2vmxdata/xml2vmx-ethernet-other.vmx | 13 ++++
tests/xml2vmxdata/xml2vmx-ethernet-other.xml | 14 ++++
tests/xml2vmxdata/xml2vmx-ethernet-static.vmx | 12 ++++
tests/xml2vmxdata/xml2vmx-ethernet-static.xml | 14 ++++
tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx | 12 ++++
tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml | 14 ++++
tests/xml2vmxtest.c | 5 ++
21 files changed, 320 insertions(+), 27 deletions(-)
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-generated.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-other.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-other.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-static.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-static.xml
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx
create mode 100644 tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-generated.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-other.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-other.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-static.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-static.xml
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx
create mode 100644 tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml
diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index b7909ff..44a144f 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -16,8 +16,8 @@
SOAP based
<a href="http://www.vmware.com/support/developer/vc-sdk/visdk25pubs/ReferenceGuide/">
VMware Virtual Infrastructure API</a> (VI API) to communicate with the
- ESX server, like the VMware Virtual Infrastructure Client does. Since
- version 4.0 this API is called
+ ESX server, like the VMware Virtual Infrastructure Client (VI client)
+ does. Since version 4.0 this API is called
<a href="http://www.vmware.com/support/developer/vc-sdk/visdk400pubs/ReferenceGuide/">
VMware vSphere API</a>.
</p>
@@ -159,7 +159,7 @@ type://[username@]hostname[:port]/[?extraparameters]
There are several specialties in the domain XML config for ESX domains.
</p>
- <h3>Restrictions</h3>
+ <h3><a name="restrictions">Restrictions</h3>
<p>
There are some restrictions for some values of the domain XML config.
The driver will complain if this restrictions are violated.
@@ -173,12 +173,13 @@ type://[username@]hostname[:port]/[?extraparameters]
</li>
<li>
Valid MAC address prefixes are <code>00:0c:29</code> and
- <code>00:50:56</code>
+ <code>00:50:56</code>. <span class="since">Since 0.7.6</span>
+ arbitrary <a href="#macaddresses">MAC addresses</a> are supported.
</li>
</ul>
- <h3>Datastore references</h3>
+ <h3><a name="datastore">Datastore references</h3>
<p>
Storage is managed in datastores. VMware uses a special path format to
reference files in a datastore. Basically, the datastore name is put
@@ -197,7 +198,68 @@ type://[username@]hostname[:port]/[?extraparameters]
</p>
- <h3>Available hardware</h3>
+ <h3><a name="macaddresses">MAC addresses</h3>
+ <p>
+ VMware has registered two MAC address prefixes for domains:
+ <code>00:0c:29</code> and <code>00:50:56</code>. These prefixes are
+ split into ranges for different purposes.
+ </p>
+ <table class="top_table">
+ <tr>
+ <th>Range</th>
+ <th>Purpose</th>
+ </tr>
+ <tr>
+ <td>
+ <code>00:0c:29:00:00:00</code> - <code>00:0c:29:ff:ff:ff</code>
+ </td>
+ <td>
+ An ESX server autogenerates MAC addresses from this range if
+ the VMX file doesn't contain a MAC address when trying to start
+ a domain.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <code>00:50:56:00:00:00</code> - <code>00:50:56:3f:ff:ff</code>
+ </td>
+ <td>
+ MAC addresses from this range can by manually assigned by the
+ user in the VI client.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <code>00:50:56:80:00:00</code> - <code>00:50:56:bf:ff:ff</code>
+ </td>
+ <td>
+ A VI client autogenerates MAC addresses from this range for
+ newly defined domains.
+ </td>
+ </tr>
+ </table>
+ <p>
+ The VMX files generated by the ESX driver always contain a MAC address,
+ because libvirt generates a random one if an interface element in the
+ domain XML file lacks a MAC address.
+ <span class="since">Since 0.7.6</span> the ESX driver sets the prefix
+ for generated MAC addresses to <code>00:0c:29</code>. Before 0.7.6
+ the <code>00:50:56</code> prefix was used. Sometimes this resulted in
+ the generation of out-of-range MAC address that were rejected by the
+ ESX server.
+ </p>
+ <p>
+ Also <span class="since">since 0.7.6</span> every MAC address outside
+ this ranges can be used. For such MAC addresses the ESX server-side
+ check is disabled in the VMX file to stop the ESX server from rejecting
+ out-of-predefined-range MAC addresses.
+ </p>
+<pre>
+ethernet0.checkMACAddress = "false"
+</pre>
+
+
+ <h3><a name="hardware">Available hardware</h3>
<p>
VMware ESX supports different models of SCSI controllers and network
cards.
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 30e21e0..f86654a 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -184,7 +184,7 @@ esxCapsInit(virConnectPtr conn)
return NULL;
}
- virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x50, 0x56 });
+ virCapabilitiesSetMacPrefix(caps, (unsigned char[]){ 0x00, 0x0c, 0x29 });
virCapabilitiesAddHostMigrateTransport(caps, "esx");
/* i686 */
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index d3cad1d..4b334b6 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -266,8 +266,8 @@ def->nets[0]...
ethernet0.addressType = "generated" # default to "generated"
- ethernet0.generatedAddressOffset = "0" # ?
->mac = <value> <=> ethernet0.generatedAddress = "<value>"
+ ethernet0.generatedAddressOffset = "0" # ?
ethernet0.addressType = "static" # default to "generated"
@@ -277,10 +277,15 @@ def->nets[0]...
ethernet0.addressType = "vpx" # default to "generated"
->mac = <value> <=> ethernet0.generatedAddress = "<value>"
+
+ ethernet0.addressType = "static" # default to "generated"
+->mac = <value> <=> ethernet0.address = "<value>"
+ ethernet0.checkMACAddress = "false" # mac address outside the VMware prefixes
+
# 00:0c:29 prefix for autogenerated mac's -> ethernet0.addressType = "generated"
# 00:50:56 prefix for manual configured mac's
# 00:50:56:00:00:00 - 00:50:56:3f:ff:ff -> ethernet0.addressType = "static"
- # 00:50:56:40:00:00 - 00:50:56:ff:ff:ff -> ethernet0.addressType = "vpx"
+ # 00:50:56:80:00:00 - 00:50:56:bf:ff:ff -> ethernet0.addressType = "vpx"
# 00:05:69 old prefix from esx 1.5
@@ -2602,6 +2607,7 @@ esxVMX_FormatEthernet(virConnectPtr conn, virDomainNetDefPtr def,
int controller, virBufferPtr buffer)
{
char mac_string[VIR_MAC_STRING_BUFLEN];
+ unsigned int prefix, suffix;
if (controller < 0 || controller > 3) {
ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
@@ -2654,33 +2660,36 @@ esxVMX_FormatEthernet(virConnectPtr conn, virDomainNetDefPtr def,
return -1;
}
+ /* def:mac -> vmx:addressType, vmx:(generated)Address, vmx:checkMACAddress */
virFormatMacAddr(def->mac, mac_string);
- if (def->mac[0] == 0x00 && def->mac[1] == 0x0c && def->mac[2] == 0x29) {
+ prefix = (def->mac[0] << 16) | (def->mac[1] << 8) | def->mac[2];
+ suffix = (def->mac[3] << 16) | (def->mac[4] << 8) | def->mac[5];
+
+ if (prefix == 0x000c29) {
virBufferVSprintf(buffer, "ethernet%d.addressType = \"generated\"\n",
controller);
virBufferVSprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n",
controller, mac_string);
virBufferVSprintf(buffer, "ethernet%d.generatedAddressOffset = \"0\"\n",
controller);
- } else if (def->mac[0] == 0x00 && def->mac[1] == 0x50 && def->mac[2] == 0x56) {
- if (def->mac[3] <= 0x3f) {
- virBufferVSprintf(buffer, "ethernet%d.addressType = \"static\"\n",
- controller);
- virBufferVSprintf(buffer, "ethernet%d.address = \"%s\"\n",
- controller, mac_string);
- } else {
- virBufferVSprintf(buffer, "ethernet%d.addressType = \"vpx\"\n",
- controller);
- virBufferVSprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n",
- controller, mac_string);
- }
+ } else if (prefix == 0x005056 && suffix <= 0x3fffff) {
+ virBufferVSprintf(buffer, "ethernet%d.addressType = \"static\"\n",
+ controller);
+ virBufferVSprintf(buffer, "ethernet%d.address = \"%s\"\n",
+ controller, mac_string);
+ } else if (prefix == 0x005056 && suffix >= 0x800000 && suffix <= 0xbfffff) {
+ virBufferVSprintf(buffer, "ethernet%d.addressType = \"vpx\"\n",
+ controller);
+ virBufferVSprintf(buffer, "ethernet%d.generatedAddress = \"%s\"\n",
+ controller, mac_string);
} else {
- ESX_ERROR(conn, VIR_ERR_INTERNAL_ERROR,
- "Unsupported MAC address prefix '%02X:%02X:%02X', expecting "
- "'00:0c:29' or '00:50:56'",
- def->mac[0], def->mac[1], def->mac[2]);
- return -1;
+ virBufferVSprintf(buffer, "ethernet%d.addressType = \"static\"\n",
+ controller);
+ virBufferVSprintf(buffer, "ethernet%d.address = \"%s\"\n",
+ controller, mac_string);
+ virBufferVSprintf(buffer, "ethernet%d.checkMACAddress = \"false\"\n",
+ controller);
}
return 0;
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx
new file mode 100644
index 0000000..f27e0a0
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-generated.vmx
@@ -0,0 +1,8 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "generated"
+ethernet0.generatedAddress = "00:0C:29:11:22:33"
+ethernet0.generatedAddressOffset = "0"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml b/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml
new file mode 100644
index 0000000..ffb203b
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-generated.xml
@@ -0,0 +1,19 @@
+<domain type='vmware'>
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
+ <memory>32768</memory>
+ <currentMemory>32768</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:0c:29:11:22:33'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx
new file mode 100644
index 0000000..da46a70
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-other.vmx
@@ -0,0 +1,8 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.checkMACAddress = "false"
+ethernet0.addressType = "static"
+ethernet0.address = "00:12:34:56:78:90"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-other.xml b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml
new file mode 100644
index 0000000..4c44fbc
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-other.xml
@@ -0,0 +1,19 @@
+<domain type='vmware'>
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
+ <memory>32768</memory>
+ <currentMemory>32768</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:12:34:56:78:90'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx
new file mode 100644
index 0000000..8b7a5b3
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-static.vmx
@@ -0,0 +1,7 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "static"
+ethernet0.address = "00:50:56:11:22:33"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-static.xml b/tests/vmx2xmldata/vmx2xml-ethernet-static.xml
new file mode 100644
index 0000000..7ef2d3d
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-static.xml
@@ -0,0 +1,19 @@
+<domain type='vmware'>
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
+ <memory>32768</memory>
+ <currentMemory>32768</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:50:56:11:22:33'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx
new file mode 100644
index 0000000..b4d9172
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.vmx
@@ -0,0 +1,7 @@
+config.version = "8"
+virtualHW.version = "4"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:87:65:43"
diff --git a/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml
new file mode 100644
index 0000000..1d90f31
--- /dev/null
+++ b/tests/vmx2xmldata/vmx2xml-ethernet-vpx.xml
@@ -0,0 +1,19 @@
+<domain type='vmware'>
+ <uuid>00000000-0000-0000-0000-000000000000</uuid>
+ <memory>32768</memory>
+ <currentMemory>32768</currentMemory>
+ <vcpu>1</vcpu>
+ <os>
+ <type arch='i686'>hvm</type>
+ </os>
+ <clock offset='utc'/>
+ <on_poweroff>destroy</on_poweroff>
+ <on_reboot>restart</on_reboot>
+ <on_crash>destroy</on_crash>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:50:56:87:65:43'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c
index 150a58d..0cb387b 100644
--- a/tests/vmx2xmltest.c
+++ b/tests/vmx2xmltest.c
@@ -139,6 +139,11 @@ mymain(int argc, char **argv)
DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25);
DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25);
+ DO_TEST("ethernet-generated", "ethernet-generated", esxVI_APIVersion_25);
+ DO_TEST("ethernet-static", "ethernet-static", esxVI_APIVersion_25);
+ DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_APIVersion_25);
+ DO_TEST("ethernet-other", "ethernet-other", esxVI_APIVersion_25);
+
DO_TEST("serial-file", "serial-file", esxVI_APIVersion_25);
DO_TEST("serial-device", "serial-device", esxVI_APIVersion_25);
DO_TEST("serial-pipe-client-app", "serial-pipe", esxVI_APIVersion_25);
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx
new file mode 100644
index 0000000..ae825a5
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-generated.vmx
@@ -0,0 +1,13 @@
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "ethernet-generated"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "generated"
+ethernet0.generatedAddress = "00:0C:29:11:22:33"
+ethernet0.generatedAddressOffset = "0"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-generated.xml b/tests/xml2vmxdata/xml2vmx-ethernet-generated.xml
new file mode 100644
index 0000000..aac8a74
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-generated.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+ <name>ethernet-generated</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:0c:29:11:22:33'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx
new file mode 100644
index 0000000..452076a
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-other.vmx
@@ -0,0 +1,13 @@
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "ethernet-static"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "static"
+ethernet0.address = "00:12:34:56:78:90"
+ethernet0.checkMACAddress = "false"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-other.xml b/tests/xml2vmxdata/xml2vmx-ethernet-other.xml
new file mode 100644
index 0000000..cf1ce7c
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-other.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+ <name>ethernet-static</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:12:34:56:78:90'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx
new file mode 100644
index 0000000..154a28b
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-static.vmx
@@ -0,0 +1,12 @@
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "ethernet-static"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "static"
+ethernet0.address = "00:50:56:11:22:33"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-static.xml b/tests/xml2vmxdata/xml2vmx-ethernet-static.xml
new file mode 100644
index 0000000..b803de4
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-static.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+ <name>ethernet-static</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:50:56:11:22:33'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx
new file mode 100644
index 0000000..31283f6
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.vmx
@@ -0,0 +1,12 @@
+config.version = "8"
+virtualHW.version = "4"
+guestOS = "other"
+uuid.bios = "56 4d 9b ef ac d9 b4 e0-c8 f0 ae a8 b9 10 35 15"
+displayName = "ethernet-vpx"
+memsize = "4"
+numvcpus = "1"
+ethernet0.present = "true"
+ethernet0.networkName = "VM Network"
+ethernet0.connectionType = "bridged"
+ethernet0.addressType = "vpx"
+ethernet0.generatedAddress = "00:50:56:87:65:43"
diff --git a/tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml
new file mode 100644
index 0000000..1490238
--- /dev/null
+++ b/tests/xml2vmxdata/xml2vmx-ethernet-vpx.xml
@@ -0,0 +1,14 @@
+<domain type='vmware'>
+ <name>ethernet-vpx</name>
+ <uuid>564d9bef-acd9-b4e0-c8f0-aea8b9103515</uuid>
+ <memory>4096</memory>
+ <os>
+ <type>hvm</type>
+ </os>
+ <devices>
+ <interface type='bridge'>
+ <mac address='00:50:56:87:65:43'/>
+ <source bridge='VM Network'/>
+ </interface>
+ </devices>
+</domain>
diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c
index abf1f32..b5b7cc8 100644
--- a/tests/xml2vmxtest.c
+++ b/tests/xml2vmxtest.c
@@ -192,6 +192,11 @@ mymain(int argc, char **argv)
DO_TEST("ethernet-custom", "ethernet-custom", esxVI_APIVersion_25);
DO_TEST("ethernet-bridged", "ethernet-bridged", esxVI_APIVersion_25);
+ DO_TEST("ethernet-generated", "ethernet-generated", esxVI_APIVersion_25);
+ DO_TEST("ethernet-static", "ethernet-static", esxVI_APIVersion_25);
+ DO_TEST("ethernet-vpx", "ethernet-vpx", esxVI_APIVersion_25);
+ DO_TEST("ethernet-other", "ethernet-other", esxVI_APIVersion_25);
+
DO_TEST("serial-file", "serial-file", esxVI_APIVersion_25);
DO_TEST("serial-device", "serial-device", esxVI_APIVersion_25);
DO_TEST("serial-pipe", "serial-pipe", esxVI_APIVersion_25);
--
1.6.0.4
14 years, 10 months
[libvirt] [PATCH] esx: Fix deserialization for VI API calls CancelTask and UnregisterVM
by Matthias Bolte
---
src/esx/esx_vi_methods.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c
index be21112..7925f26 100644
--- a/src/esx/esx_vi_methods.c
+++ b/src/esx/esx_vi_methods.c
@@ -601,7 +601,7 @@ esxVI_CancelTask(virConnectPtr conn, esxVI_Context *ctx,
request = virBufferContentAndReset(&buffer);
- if (esxVI_Context_Execute(conn, ctx, "UnregisterVM", request, &response,
+ if (esxVI_Context_Execute(conn, ctx, "CancelTask", request, &response,
esxVI_Occurrence_None) < 0) {
goto failure;
}
@@ -652,7 +652,7 @@ esxVI_UnregisterVM(virConnectPtr conn, esxVI_Context *ctx,
request = virBufferContentAndReset(&buffer);
- if (esxVI_Context_Execute(conn, ctx, "AnswerVM", request, &response,
+ if (esxVI_Context_Execute(conn, ctx, "UnregisterVM", request, &response,
esxVI_Occurrence_None) < 0) {
goto failure;
}
--
1.6.0.4
14 years, 10 months
[libvirt] [PATCH] esx: Fix and improve the libcurl debug callback
by Matthias Bolte
The data passed to the callback is not guaranteed to be zero terminated,
take care of that by coping the data and adding a zero terminator.
Also dump the data for other types than CURLINFO_TEXT.
Set CURLOPT_VERBOSE to 1 so the debug callback is called when enabled.
---
src/esx/esx_vi.c | 43 ++++++++++++++++++++++++++++++++++---------
1 files changed, 34 insertions(+), 9 deletions(-)
diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c
index a7498f0..bad987c 100644
--- a/src/esx/esx_vi.c
+++ b/src/esx/esx_vi.c
@@ -181,27 +181,50 @@ static int
esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type,
char *info, size_t size, void *data ATTRIBUTE_UNUSED)
{
+ char *buffer = NULL;
+
+ /*
+ * The libcurl documentation says:
+ *
+ * The data pointed to by the char * passed to this function WILL NOT
+ * be zero terminated, but will be exactly of the size as told by the
+ * size_t argument.
+ *
+ * To handle this properly in order to pass the info string to VIR_DEBUG
+ * a zero terminated copy of the info string has to be allocated.
+ */
+ if (VIR_ALLOC_N(buffer, size + 1) < 0) {
+ return 0;
+ }
+
+ if (virStrncpy(buffer, info, size, size + 1) == NULL) {
+ VIR_FREE(buffer);
+ return 0;
+ }
+
switch (type) {
case CURLINFO_TEXT:
- VIR_DEBUG0("CURLINFO_TEXT");
- fwrite(info, 1, size, stderr);
- printf("\n\n");
+ if (size > 0 && buffer[size - 1] == '\n') {
+ buffer[size - 1] = '\0';
+ }
+
+ VIR_DEBUG("CURLINFO_TEXT [[[[%s]]]]", buffer);
break;
case CURLINFO_HEADER_IN:
- VIR_DEBUG0("CURLINFO_HEADER_IN");
+ VIR_DEBUG("CURLINFO_HEADER_IN [[[[%s]]]]", buffer);
break;
case CURLINFO_HEADER_OUT:
- VIR_DEBUG0("CURLINFO_HEADER_OUT");
+ VIR_DEBUG("CURLINFO_HEADER_OUT [[[[%s]]]]", buffer);
break;
case CURLINFO_DATA_IN:
- VIR_DEBUG0("CURLINFO_DATA_IN");
+ VIR_DEBUG("CURLINFO_DATA_IN [[[[%s]]]]", buffer);
break;
case CURLINFO_DATA_OUT:
- VIR_DEBUG0("CURLINFO_DATA_OUT");
+ VIR_DEBUG("CURLINFO_DATA_OUT [[[[%s]]]]", buffer);
break;
default:
@@ -209,6 +232,8 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type,
break;
}
+ VIR_FREE(buffer);
+
return 0;
}
#endif
@@ -338,8 +363,8 @@ esxVI_Context_Connect(virConnectPtr conn, esxVI_Context *ctx, const char *url,
curl_easy_setopt(ctx->curl_handle, CURLOPT_WRITEFUNCTION,
esxVI_CURL_WriteBuffer);
#if ESX_VI__CURL__ENABLE_DEBUG_OUTPUT
- curl_easy_setopt(ctx->curl_handle, CURLOPT_DEBUGFUNCTION,
- esxVI_CURL_Debug);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_DEBUGFUNCTION, esxVI_CURL_Debug);
+ curl_easy_setopt(ctx->curl_handle, CURLOPT_VERBOSE, 1);
#endif
if (virMutexInit(&ctx->curl_lock) < 0) {
--
1.6.0.4
14 years, 10 months
[libvirt] [PATCH] esx: Don't warn about an empty URI path
by Matthias Bolte
---
src/esx/esx_driver.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 5cdadfd..30e21e0 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -293,7 +293,8 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
return VIR_DRV_OPEN_DECLINED;
}
- if (conn->uri->path != NULL && STRNEQ(conn->uri->path, "/")) {
+ if (conn->uri->path != NULL && STRNEQ(conn->uri->path, "") &&
+ STRNEQ(conn->uri->path, "/")) {
VIR_WARN("Ignoring unexpected path '%s' in URI", conn->uri->path);
}
--
1.6.0.4
14 years, 10 months