[libvirt] [PATCH] lxc: Fix error handlings of veth functions
by Ryota Ozaki
moveInterfaceToNetNs and vethInterfaceUpOrDown may return a
positive value when they fail. We should check if the value
is not zero instead of checking if it's negative.
This defect may be related to the bug:
https://bugzilla.redhat.com/show_bug.cgi?id=607496 .
It would not fix the bug, but would unveil what happens.
And also, the return value of positive is an exit code, not
an errno. So we should not use virReportSystemError.
Note that there still remains a problem that the descriptions
of the functions are wrong; they say that the return value
will be -1 on failure, however, they would actually return a
positive value. The inconsistent should be fixed at some point.
---
src/lxc/lxc_container.c | 7 ++++++-
src/lxc/lxc_controller.c | 2 +-
src/lxc/lxc_driver.c | 12 ++++++------
3 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 4371dba..c77d262 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -273,8 +273,13 @@ static int lxcContainerRenameAndEnableInterfaces(unsigned int nveths,
}
/* enable lo device only if there were other net devices */
- if (veths)
+ if (veths) {
rc = vethInterfaceUpOrDown("lo", 1);
+ if (0 != rc) {
+ VIR_ERROR(_("Failed to enable lo (%d)"), rc);
+ rc = -1;
+ }
+ }
error_out:
VIR_FREE(newname);
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index d8b7bc7..9829a69 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -477,7 +477,7 @@ static int lxcControllerMoveInterfaces(unsigned int nveths,
{
unsigned int i;
for (i = 0 ; i < nveths ; i++)
- if (moveInterfaceToNetNs(veths[i], container) < 0) {
+ if (moveInterfaceToNetNs(veths[i], container) != 0) {
lxcError(VIR_ERR_INTERNAL_ERROR,
_("Failed to move interface %s to ns %d"),
veths[i], container);
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 4fc1ecd..51c273e 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -886,9 +886,9 @@ static int lxcSetupInterfaces(virConnectPtr conn,
char macaddr[VIR_MAC_STRING_BUFLEN];
virFormatMacAddr(def->nets[i]->mac, macaddr);
if (0 != (rc = setMacAddr(containerVeth, macaddr))) {
- virReportSystemError(rc,
- _("Failed to set %s to %s"),
- macaddr, containerVeth);
+ lxcError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to set %s to %s (%d)"),
+ macaddr, containerVeth, rc);
goto error_exit;
}
}
@@ -901,9 +901,9 @@ static int lxcSetupInterfaces(virConnectPtr conn,
}
if (0 != (rc = vethInterfaceUpOrDown(parentVeth, 1))) {
- virReportSystemError(rc,
- _("Failed to enable %s device"),
- parentVeth);
+ lxcError(VIR_ERR_INTERNAL_ERROR,
+ _("Failed to enable %s device (%d)"),
+ parentVeth, rc);
goto error_exit;
}
--
1.6.6.1
14 years, 3 months
[libvirt] [PATCH] Fix a potential race in pciInitDevice.
by Chris Lalancette
If detecting the FLR flag of a pci device fails, then we
could run into the situation of trying to close a file
descriptor twice, once in pciInitDevice() and once in pciFreeDevice().
Fix that by removing the pciCloseConfig() in pciInitDevice() and
just letting pciFreeDevice() handle it.
Thanks to Chris Wright for pointing out this problem.
While we are at it, fix an error check. While it would actually
work as-is (since success returns 0), it's still more clear to
check for < 0 (as the rest of the code does).
Signed-off-by: Chris Lalancette <clalance(a)redhat.com>
---
src/qemu/qemu_driver.c | 2 +-
src/util/pci.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index b4c468a..9436e2a 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -8010,7 +8010,7 @@ static int qemudDomainAttachHostPciDevice(struct qemud_driver *driver,
return -1;
}
- if (qemuPrepareHostdevPCIDevices(driver, &hostdev, 1))
+ if (qemuPrepareHostdevPCIDevices(driver, &hostdev, 1) < 0)
return -1;
if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
diff --git a/src/util/pci.c b/src/util/pci.c
index 14ef058..26d55b8 100644
--- a/src/util/pci.c
+++ b/src/util/pci.c
@@ -189,8 +189,10 @@ pciCloseConfig(pciDevice *dev)
if (!dev)
return;
- if (dev->fd >= 0)
+ if (dev->fd >= 0) {
close(dev->fd);
+ dev->fd = -1;
+ }
}
static int
@@ -673,10 +675,8 @@ pciInitDevice(pciDevice *dev)
dev->pcie_cap_pos = pciFindCapabilityOffset(dev, PCI_CAP_ID_EXP);
dev->pci_pm_cap_pos = pciFindCapabilityOffset(dev, PCI_CAP_ID_PM);
flr = pciDetectFunctionLevelReset(dev);
- if (flr < 0) {
- pciCloseConfig(dev);
+ if (flr < 0)
return flr;
- }
dev->has_flr = flr;
dev->has_pm_reset = pciDetectPowerManagementReset(dev);
dev->initted = 1;
--
1.7.1.1
14 years, 3 months
[libvirt] [PATCH 0/6 v2] qemu: virtio console support
by Cole Robinson
The following series adds virtio console XML and qemu driver support.
The first 5 patches are testing, documentation, and internal cleanups to
prepare for the actual support added in patch 6.
Changes from v1:
Add more regression tests
Always show an explicit <console> target type in the XML
Drop multiple console support (there be dragons)
Drop name attribute from virtio <console> target
Cole Robinson (6):
tests: Test qemuxml2xml when expected xml changes
docs: domain: Document virtio <channel>
domain conf: Rename character prop targetType -> deviceType
domain conf: char: Add an explicit targetType field
domain conf: Track <console> target type
qemu: virtio console support
docs/formatdomain.html.in | 30 ++-
docs/schemas/domain.rng | 35 ++-
src/conf/capabilities.h | 1 +
src/conf/domain_conf.c | 462 +++++++++++++-------
src/conf/domain_conf.h | 37 ++-
src/esx/esx_vmx.c | 4 +-
src/libvirt_private.syms | 1 +
src/qemu/qemu_conf.c | 54 ++-
src/qemu/qemu_driver.c | 4 +-
src/uml/uml_conf.c | 2 +
src/vbox/vbox_tmpl.c | 4 +-
src/xen/xen_hypervisor.c | 2 +
src/xen/xend_internal.c | 7 +-
src/xen/xm_internal.c | 7 +-
tests/Makefile.am | 1 +
tests/define-dev-segfault | 2 +-
tests/domainschematest | 2 +-
.../qemuxml2argv-balloon-device-auto.args | 1 +
.../qemuxml2argv-balloon-device-auto.xml | 22 +
.../qemuxml2argv-console-compat-auto.args | 1 +
.../qemuxml2argv-console-compat-auto.xml | 28 ++
.../qemuxml2argv-console-compat.xml | 2 +-
.../qemuxml2argv-console-virtio.args | 1 +
.../qemuxml2argv-console-virtio.xml | 27 ++
.../qemuxml2argv-disk-scsi-device-auto.args | 1 +
.../qemuxml2argv-disk-scsi-device-auto.xml | 28 ++
.../qemuxml2argv-disk-scsi-device.args | 1 +
.../qemuxml2argv-disk-scsi-device.xml | 31 ++
tests/qemuxml2argvdata/qemuxml2argv-serial-dev.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-serial-file.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-serial-many.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-serial-pty.xml | 2 +-
.../qemuxml2argv-serial-tcp-telnet.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-serial-udp.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-serial-unix.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-serial-vc.xml | 2 +-
tests/qemuxml2argvtest.c | 9 +
.../qemuxml2xmlout-balloon-device-auto.xml | 25 +
.../qemuxml2xmlout-channel-virtio-auto.xml | 54 +++
.../qemuxml2xmlout-console-compat-auto.xml | 31 ++
.../qemuxml2xmlout-console-virtio.xml | 29 ++
.../qemuxml2xmlout-disk-scsi-device-auto.xml | 31 ++
tests/qemuxml2xmltest.c | 80 +++-
tests/sexpr2xmldata/sexpr2xml-bridge-ipaddr.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-curmem.xml | 2 +-
.../sexpr2xml-disk-block-shareable.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-disk-block.xml | 2 +-
.../sexpr2xml-disk-drv-blktap-qcow.xml | 2 +-
.../sexpr2xml-disk-drv-blktap-raw.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-disk-file.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-autoport.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-kernel.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-file.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-null.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-pipe.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-pty.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-stdio.xml | 2 +-
.../sexpr2xml-fv-serial-tcp-telnet.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-tcp.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-udp.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-fv-serial-unix.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-net-bridged.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-net-e1000.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-net-routed.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pci-devs.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-bootloader.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-localtime.xml | 2 +-
.../sexpr2xml-pv-vfb-new-vncdisplay.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-vfb-new.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv-vfb-orig.xml | 2 +-
.../sexpr2xmldata/sexpr2xml-pv-vfb-type-crash.xml | 2 +-
tests/sexpr2xmldata/sexpr2xml-pv.xml | 2 +-
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-4.xml | 2 +-
tests/vmx2xmldata/vmx2xml-serial-device.xml | 2 +-
tests/vmx2xmldata/vmx2xml-serial-file.xml | 2 +-
tests/vmx2xmldata/vmx2xml-serial-pipe.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-file.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-null.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-pipe.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-pty.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-stdio.xml | 2 +-
.../test-fullvirt-serial-tcp-telnet.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-tcp.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-udp.xml | 2 +-
tests/xmconfigdata/test-fullvirt-serial-unix.xml | 2 +-
tests/xmconfigdata/test-no-source-cdrom.xml | 2 +-
tests/xmconfigdata/test-paravirt-net-e1000.xml | 2 +-
tests/xmconfigdata/test-paravirt-net-vifname.xml | 2 +-
.../test-paravirt-new-pvfb-vncdisplay.xml | 2 +-
tests/xmconfigdata/test-paravirt-new-pvfb.xml | 2 +-
.../test-paravirt-old-pvfb-vncdisplay.xml | 2 +-
tests/xmconfigdata/test-paravirt-old-pvfb.xml | 2 +-
tests/xmconfigdata/test-pci-devs.xml | 2 +-
95 files changed, 900 insertions(+), 277 deletions(-)
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-balloon-device-auto.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-compat-auto.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-console-virtio.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device-auto.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-disk-scsi-device.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-balloon-device-auto.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-channel-virtio-auto.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-console-compat-auto.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-console-virtio.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-scsi-device-auto.xml
14 years, 3 months
[libvirt] Extensions to the libvirt Storage API
by Patrick Dignan
Hi Everyone,
I'm looking at implementing some functionality in libvirt that would
allow it to call functions in an unpublished iSCSI library. Some of the
functionality I wish to implement is not currently part of the libvirt
storage API. I wanted to suggest the following additions to the storage
API: grow volumes, show whether thin provisioning is enabled, enable
thin provisioning, disable thin provisioning, create snapshots, and
delete snapshots. I've added a patch at the end of the mail showing how
I think these functions should be implemented. Note that I have not
included details about the virStorageSnapshotDefPtr yet, that's the next
step.
Perhaps this should be in a separate mail for better threading, but it
seems a bit strange to me that the storage interface isn't pluggable in
the traditional sense. In order to add a backend to libvirt, one has to
make modifications all over the place, for example: virt-inst, the
Makefile.am, the configure.ac, storage_backend.h, and several other
places. It would make sense to me to make this pluggable such that
someone could just load in a library that implements the required
functions and some identifying information (eg type of storage,
description, etc). A list of supported backends could be stored in
empty files in a directory somewhere, or some similar hack. This way
someone could write a plugin for tgtd for example, or in my case the
library I'm working with. I think this would also help others with
writing plugins for more storage backends. How difficult do you think
this would be? I'm willing to do a reasonable amount of work to get
this implemented, but I want to know what the experts think!
Best,
Patrick Dignan
--- libvirt-0.8.2.orig/src/storage/storage_backend.h 2010-06-16
17:27:22.000000000 -0500
+++ libvirt-0.8.2.work/src/storage/storage_backend.h 2010-07-27
16:36:08.321439851 -0500
@@ -43,6 +43,13 @@
typedef int (*virStorageBackendBuildVolFrom)(virConnectPtr conn,
virStoragePoolObjPtr pool,
virStorageVolDefPtr
origvol, virStorageVolDefPtr newvol,
unsigned int flags);
+typedef int (*virStorageBackendGrowVol)(virConnectPtr conn,
virStoragePoolObjPtr pool, virStorageVolDefPtr vol, unsigned long long
newsize);
+typedef bool (*virStorageBackendThinProvisionShow)(virConnectPtr conn,
virStoragePoolObjPtr pool, virStorageVolDefPtr vol);
+typedef int (*virStorageBackendThinProvisionEnable)(virConnectPtr conn,
virStoragePoolObjPtr pool, virStorageVolDefPtr vol);
+typedef int (*virStorageBackendThinProvisionDisable)(virConnectPtr
conn, virStoragePoolObjPtr pool, virStorageVolDefPtr vol);
+
+typedef int (virStorageBackendCreateSnapshot)(virConnectPtr conn,
virStoragePoolObjPtr pool, virStorageVolDefPtr vol,
virStorageSnapshotDefPtr snapshot);
+typedef int (virStorageBackendDeleteSnapshot)(virConnectPtr conn,
virStoragePoolObjPtr pool, virStorageVolDefPtr vol,
virStorageSnapshotDefPtr snapshot);
/* File creation/cloning functions used for cloning between backends */
int virStorageBackendCreateRaw(virConnectPtr conn,
@@ -76,6 +83,12 @@
virStorageBackendCreateVol createVol;
virStorageBackendRefreshVol refreshVol;
virStorageBackendDeleteVol deleteVol;
+ virStorageBackendGrowVol growVol;
+ virStorageBackendThinProvisionShow thinProvisionShow;
+ virStorageBackendThinProvisionEnable thinProvisionEnable;
+ virStorageBackendThinProvisionDisable thinProvisionDisable;
+ virStorageBackendCreateSnapshot createSnapshot;
+ virStorageBackendDeleteSnapshot deleteSnapshot;
};
virStorageBackendPtr virStorageBackendForType(int type);
14 years, 3 months
[libvirt] [PATCH] esx: Add vpx:// scheme to allow direct connection to a vCenter
by Matthias Bolte
Add a pointer to the primary context of a connection and use it in all
driver functions that don't dependent on the context type. This includes
almost all functions that deal with a virDomianPtr. Therefore, using
a vpx:// connection allows you to perform all the usual domain related
actions like start, destroy, suspend, resume, dumpxml etc.
Some functions that require an explicitly specified ESX server don't work
yet. This includes the host UUID, the hostname, the general node info, the
max vCPU count and the free memory. Also not working yet are migration and
defining new domains.
---
docs/drvesx.html.in | 21 +-
src/esx/esx_driver.c | 931 ++++++++++++++++++++++++------------------
src/esx/esx_private.h | 1 +
src/esx/esx_storage_driver.c | 33 +-
src/esx/esx_vmx.c | 2 +
src/libvirt.c | 1 +
6 files changed, 562 insertions(+), 427 deletions(-)
diff --git a/docs/drvesx.html.in b/docs/drvesx.html.in
index e8cee77..1f2ae4e 100644
--- a/docs/drvesx.html.in
+++ b/docs/drvesx.html.in
@@ -4,13 +4,14 @@
<p>
The libvirt VMware ESX driver can manage VMware ESX/ESXi 3.5/4.0 and
VMware GSX 2.0, also called VMware Server 2.0, and possibly later
- versions.
+ versions. <span class="since">Since 0.8.3</span> the driver can also
+ connect to a VMware vCenter 2.5/4.0 (VPX).
</p>
<h2><a name="prereq">Deployment pre-requisites</a></h2>
<p>
- None. Any out-of-the-box installation of ESX/GSX should work. No
+ None. Any out-of-the-box installation of VPX/ESX(i)/GSX should work. No
preparations are required on the server side, no libvirtd must be
installed on the ESX server. The driver uses version 2.5 of the remote,
SOAP based
@@ -27,10 +28,11 @@
Some example remote connection URIs for the driver are:
</p>
<pre>
-esx://example.com (ESX over HTTPS)
-gsx://example.com (GSX over HTTPS)
-esx://example.com/?transport=http (ESX over HTTP)
-esx://example.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the server's SSL certificate)
+vpx://example-vcenter.com (VPX over HTTPS)
+esx://example-esx.com (ESX over HTTPS)
+gsx://example-gsx.com (GSX over HTTPS)
+esx://example-esx.com/?transport=http (ESX over HTTP)
+esx://example-esx.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the server's SSL certificate)
</pre>
<p>
<strong>Note</strong>: In contrast to other drivers, the ESX driver is
@@ -49,9 +51,9 @@ esx://example.com/?no_verify=1 (ESX over HTTPS, but doesn't verify the serve
type://[username@]hostname[:port]/[?extraparameters]
</pre>
<p>
- The <code>type://</code> is either <code>esx://</code> or
+ The <code>type://</code> is either <code>vpx://</code> or <code>esx://</code> or
<code>gsx://</code> and the driver selects the default port depending
- on it. For ESX the default HTTPS port is 443, for GSX it is 8333. If
+ on it. For VPX and ESX the default HTTPS port is 443, for GSX it is 8333. If
the port parameter is given, it overrides the default port.
</p>
@@ -76,7 +78,7 @@ type://[username@]hostname[:port]/[?extraparameters]
<code>http</code> or <code>https</code>
</td>
<td>
- Overrides the default HTTPS transport. For ESX the default
+ Overrides the default HTTPS transport. For VPX and ESX the default
HTTP port is 80, for GSX it is 8222.
</td>
</tr>
@@ -91,6 +93,7 @@ type://[username@]hostname[:port]/[?extraparameters]
In order to perform a migration the driver needs to know the
VMware vCenter for the ESX server. If set to <code>*</code>,
the driver connects to the vCenter known to the ESX server.
+ This paramater in useful when connecting to an ESX server only.
</td>
</tr>
<tr>
diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c
index 33f421d..5922cb6 100644
--- a/src/esx/esx_driver.c
+++ b/src/esx/esx_driver.c
@@ -67,6 +67,11 @@ esxSupportsLongMode(esxPrivate *priv)
return priv->supportsLongMode;
}
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ return esxVI_Boolean_False;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return esxVI_Boolean_Undefined;
}
@@ -148,6 +153,11 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid)
esxVI_ObjectContent *hostSystem = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ return 0;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return -1;
}
@@ -280,11 +290,204 @@ esxCapsInit(esxPrivate *priv)
+static int
+esxConnectToHost(esxPrivate *priv, virConnectAuthPtr auth,
+ const char *hostname, int port,
+ const char *predefinedUsername,
+ esxUtil_ParsedQuery *parsedQuery,
+ esxVI_ProductVersion expectedProductVersion,
+ char **vCenterIpAddress)
+{
+ int result = -1;
+ char ipAddress[NI_MAXHOST] = "";
+ char *username = NULL;
+ char *password = NULL;
+ char *url = NULL;
+ esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *hostSystem = NULL;
+ esxVI_Boolean inMaintenanceMode = esxVI_Boolean_Undefined;
+
+ if (vCenterIpAddress == NULL || *vCenterIpAddress != NULL) {
+ ESX_VI_ERROR(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument"));
+ return -1;
+ }
+
+ if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) {
+ return -1;
+ }
+
+ if (predefinedUsername != NULL) {
+ username = strdup(predefinedUsername);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else {
+ username = virRequestUsername(auth, "root", hostname);
+
+ if (username == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
+ goto cleanup;
+ }
+ }
+
+ password = virRequestPassword(auth, username, hostname);
+
+ if (password == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
+ goto cleanup;
+ }
+
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
+ port) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (esxVI_Context_Alloc(&priv->host) < 0 ||
+ esxVI_Context_Connect(priv->host, url, ipAddress, username, password,
+ parsedQuery) < 0) {
+ goto cleanup;
+ }
+
+ if (expectedProductVersion == esxVI_ProductVersion_ESX) {
+ if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
+ priv->host->productVersion != esxVI_ProductVersion_ESX40) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("%s is neither an ESX 3.5 host nor an ESX 4.0 host"),
+ hostname);
+ goto cleanup;
+ }
+ } else { /* GSX */
+ if (priv->host->productVersion != esxVI_ProductVersion_GSX20) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("%s isn't a GSX 2.0 host"), hostname);
+ goto cleanup;
+ }
+ }
+
+ /* Query the host for maintenance mode and vCenter IP address */
+ if (esxVI_String_AppendValueListToList(&propertyNameList,
+ "runtime.inMaintenanceMode\0"
+ "summary.managementServerIp\0") < 0 ||
+ esxVI_LookupHostSystemByIp(priv->host, ipAddress, propertyNameList,
+ &hostSystem) < 0 ||
+ esxVI_GetBoolean(hostSystem, "runtime.inMaintenanceMode",
+ &inMaintenanceMode,
+ esxVI_Occurrence_RequiredItem) < 0 ||
+ esxVI_GetStringValue(hostSystem, "summary.managementServerIp",
+ vCenterIpAddress,
+ esxVI_Occurrence_OptionalItem) < 0) {
+ goto cleanup;
+ }
+
+ /* Warn if host is in maintenance mode */
+ if (inMaintenanceMode == esxVI_Boolean_True) {
+ VIR_WARN0("The server is in maintenance mode");
+ }
+
+ if (*vCenterIpAddress != NULL) {
+ *vCenterIpAddress = strdup(*vCenterIpAddress);
+
+ if (*vCenterIpAddress == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ }
+
+ result = 0;
+
+ cleanup:
+ VIR_FREE(password);
+ VIR_FREE(username);
+ VIR_FREE(url);
+ esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&hostSystem);
+
+ return result;
+}
+
+
+
+static int
+esxConnectToVCenter(esxPrivate *priv, virConnectAuthPtr auth,
+ const char *hostname, int port,
+ const char *predefinedUsername,
+ esxUtil_ParsedQuery *parsedQuery)
+{
+ int result = -1;
+ char ipAddress[NI_MAXHOST] = "";
+ char *username = NULL;
+ char *password = NULL;
+ char *url = NULL;
+
+ if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) {
+ return -1;
+ }
+
+ if (predefinedUsername != NULL) {
+ username = strdup(predefinedUsername);
+
+ if (username == NULL) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ } else {
+ username = virRequestUsername(auth, "administrator", hostname);
+
+ if (username == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
+ goto cleanup;
+ }
+ }
+
+ password = virRequestPassword(auth, username, hostname);
+
+ if (password == NULL) {
+ ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
+ goto cleanup;
+ }
+
+ if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport, hostname,
+ port) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (esxVI_Context_Alloc(&priv->vCenter) < 0 ||
+ esxVI_Context_Connect(priv->vCenter, url, ipAddress, username,
+ password, parsedQuery) < 0) {
+ goto cleanup;
+ }
+
+ if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
+ priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("%s is neither a vCenter 2.5 server nor a vCenter "
+ "4.0 server"), hostname);
+ goto cleanup;
+ }
+
+ result = 0;
+
+ cleanup:
+ VIR_FREE(password);
+ VIR_FREE(username);
+ VIR_FREE(url);
+
+ return result;
+}
+
+
+
/*
- * URI format: {esx|gsx}://[<username>@]<hostname>[:<port>]/[<query parameter> ...]
+ * URI format: {vpx|esx|gsx}://[<username>@]<hostname>[:<port>]/[<query parameter> ...]
*
* If no port is specified the default port is set dependent on the scheme and
* transport parameter:
+ * - vpx+http 80
+ * - vpx+https 443
* - esx+http 80
* - esx+https 443
* - gsx+http 8222
@@ -292,7 +495,7 @@ esxCapsInit(esxPrivate *priv)
*
* Optional query parameters:
* - transport={http|https}
- * - vcenter={<vcenter>|*}
+ * - vcenter={<vcenter>|*} only useful for an esx:// connection
* - no_verify={0|1}
* - auto_answer={0|1}
* - proxy=[{http|socks|socks4|socks4a|socks5}://]<hostname>[:<port>]
@@ -322,19 +525,13 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
virDrvOpenStatus result = VIR_DRV_OPEN_ERROR;
esxPrivate *priv = NULL;
esxUtil_ParsedQuery *parsedQuery = NULL;
- char hostIpAddress[NI_MAXHOST] = "";
+ char *potentialVCenterIpAddress = NULL;
char vCenterIpAddress[NI_MAXHOST] = "";
- char *url = NULL;
- char *vCenter = NULL;
- char *username = NULL;
- char *password = NULL;
- esxVI_String *propertyNameList = NULL;
- esxVI_ObjectContent *hostSystem = NULL;
- esxVI_DynamicProperty *dynamicProperty = NULL;
- /* Decline if the URI is NULL or the scheme is neither 'esx' nor 'gsx' */
+ /* Decline if the URI is NULL or the scheme is not one of {vpx|esx|gsx} */
if (conn->uri == NULL || conn->uri->scheme == NULL ||
- (STRCASENEQ(conn->uri->scheme, "esx") &&
+ (STRCASENEQ(conn->uri->scheme, "vpx") &&
+ STRCASENEQ(conn->uri->scheme, "esx") &&
STRCASENEQ(conn->uri->scheme, "gsx"))) {
return VIR_DRV_OPEN_DECLINED;
}
@@ -376,7 +573,8 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
* distinguish between the situations port == 0 and port != 0
*/
if (conn->uri->port == 0) {
- if (STRCASEEQ(conn->uri->scheme, "esx")) {
+ if (STRCASEEQ(conn->uri->scheme, "vpx") ||
+ STRCASEEQ(conn->uri->scheme, "esx")) {
if (STRCASEEQ(priv->transport, "https")) {
conn->uri->port = 443;
} else {
@@ -391,194 +589,67 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
}
- /* Login to host */
- if (esxUtil_ResolveHostname(conn->uri->server, hostIpAddress,
- NI_MAXHOST) < 0) {
- goto cleanup;
- }
-
- if (virAsprintf(&url, "%s://%s:%d/sdk", priv->transport,
- conn->uri->server, conn->uri->port) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-
- if (conn->uri->user != NULL) {
- username = strdup(conn->uri->user);
-
- if (username == NULL) {
- virReportOOMError();
- goto cleanup;
- }
- } else {
- username = virRequestUsername(auth, "root", conn->uri->server);
-
- if (username == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
- goto cleanup;
- }
- }
-
- password = virRequestPassword(auth, username, conn->uri->server);
-
- if (password == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
- goto cleanup;
- }
-
- if (esxVI_Context_Alloc(&priv->host) < 0 ||
- esxVI_Context_Connect(priv->host, url, hostIpAddress, username,
- password, parsedQuery) < 0) {
- goto cleanup;
- }
-
- if (STRCASEEQ(conn->uri->scheme, "esx")) {
- if (priv->host->productVersion != esxVI_ProductVersion_ESX35 &&
- priv->host->productVersion != esxVI_ProductVersion_ESX40) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("%s is neither an ESX 3.5 host nor an ESX 4.0 host"),
- conn->uri->server);
+ if (STRCASEEQ(conn->uri->scheme, "esx") ||
+ STRCASEEQ(conn->uri->scheme, "gsx")) {
+ /* Connect to host */
+ if (esxConnectToHost(priv, auth, conn->uri->server, conn->uri->port,
+ conn->uri->user, parsedQuery,
+ STRCASEEQ(conn->uri->scheme, "esx")
+ ? esxVI_ProductVersion_ESX
+ : esxVI_ProductVersion_GSX,
+ &potentialVCenterIpAddress) < 0) {
goto cleanup;
}
- } else { /* GSX */
- if (priv->host->productVersion != esxVI_ProductVersion_GSX20) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("%s isn't a GSX 2.0 host"), conn->uri->server);
- goto cleanup;
- }
- }
-
- /* Query the host for maintenance mode and vCenter IP address */
- if (esxVI_String_AppendValueListToList(&propertyNameList,
- "runtime.inMaintenanceMode\0"
- "summary.managementServerIp\0") < 0 ||
- esxVI_LookupHostSystemByIp(priv->host, hostIpAddress, propertyNameList,
- &hostSystem) < 0) {
- goto cleanup;
- }
- /* Warn if host is in maintenance mode */
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "runtime.inMaintenanceMode")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_Boolean) < 0) {
- goto cleanup;
- }
-
- if (dynamicProperty->val->boolean == esxVI_Boolean_True) {
- VIR_WARN0("The server is in maintenance mode");
- }
-
- break;
- }
- }
-
- /* Login to vCenter */
- if (parsedQuery->vCenter != NULL) {
- VIR_FREE(url);
- VIR_FREE(password);
- VIR_FREE(username);
-
- vCenter = strdup(parsedQuery->vCenter);
-
- if (vCenter == NULL) {
- virReportOOMError();
- goto cleanup;
- }
-
- /* If a vCenter is specified resolve the hostname */
- if (STRNEQ(vCenter, "*") &&
- esxUtil_ResolveHostname(vCenter, vCenterIpAddress,
- NI_MAXHOST) < 0) {
- goto cleanup;
- }
-
- /* Lookup the vCenter from the ESX host */
- for (dynamicProperty = hostSystem->propSet; dynamicProperty != NULL;
- dynamicProperty = dynamicProperty->_next) {
- if (STREQ(dynamicProperty->name, "summary.managementServerIp")) {
- if (esxVI_AnyType_ExpectType(dynamicProperty->val,
- esxVI_Type_String) < 0) {
+ /* Connect to vCenter */
+ if (parsedQuery->vCenter != NULL) {
+ if (STREQ(parsedQuery->vCenter, "*")) {
+ if (potentialVCenterIpAddress == NULL) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("This host is not managed by a vCenter"));
goto cleanup;
}
- /* Get the vCenter IP address or verify the specified one */
- if (STREQ(vCenter, "*")) {
- VIR_FREE(vCenter);
-
- vCenter = strdup(dynamicProperty->val->string);
-
- if (vCenter == NULL) {
- virReportOOMError();
- goto cleanup;
- }
+ if (virStrcpyStatic(vCenterIpAddress,
+ potentialVCenterIpAddress) == NULL) {
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
+ _("vCenter IP address %s too big for destination"),
+ potentialVCenterIpAddress);
+ goto cleanup;
+ }
+ } else {
+ if (esxUtil_ResolveHostname(parsedQuery->vCenter,
+ vCenterIpAddress, NI_MAXHOST) < 0) {
+ goto cleanup;
+ }
- if (virStrcpyStatic(vCenterIpAddress,
- dynamicProperty->val->string) == NULL) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("vCenter IP address %s too big for "
- "destination"),
- dynamicProperty->val->string);
- goto cleanup;
- }
- } else if (STRNEQ(vCenterIpAddress,
- dynamicProperty->val->string)) {
+ if (potentialVCenterIpAddress != NULL &&
+ STRNEQ(vCenterIpAddress, potentialVCenterIpAddress)) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("This host is managed by a vCenter with IP "
"address %s, but a mismachting vCenter '%s' "
"(%s) has been specified"),
- dynamicProperty->val->string, vCenter,
+ potentialVCenterIpAddress, parsedQuery->vCenter,
vCenterIpAddress);
goto cleanup;
}
-
- break;
}
- }
-
- if (STREQ(vCenter, "*")) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
- _("This host is not managed by a vCenter"));
- goto cleanup;
- }
-
- if (virAsprintf(&url, "%s://%s/sdk", priv->transport,
- vCenter) < 0) {
- virReportOOMError();
- goto cleanup;
- }
-
- if (esxVI_Context_Alloc(&priv->vCenter) < 0) {
- goto cleanup;
- }
- username = virRequestUsername(auth, "administrator", vCenter);
-
- if (username == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Username request failed"));
- goto cleanup;
- }
-
- password = virRequestPassword(auth, username, vCenter);
-
- if (password == NULL) {
- ESX_ERROR(VIR_ERR_AUTH_FAILED, "%s", _("Password request failed"));
- goto cleanup;
+ if (esxConnectToVCenter(priv, auth, vCenterIpAddress,
+ conn->uri->port, NULL, parsedQuery) < 0) {
+ goto cleanup;
+ }
}
- if (esxVI_Context_Connect(priv->vCenter, url, vCenterIpAddress,
- username, password, parsedQuery) < 0) {
+ priv->primary = priv->host;
+ } else { /* VPX */
+ /* Connect to vCenter */
+ if (esxConnectToVCenter(priv, auth, conn->uri->server, conn->uri->port,
+ conn->uri->user, parsedQuery) < 0) {
goto cleanup;
}
- if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 &&
- priv->vCenter->productVersion != esxVI_ProductVersion_VPX40) {
- ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
- _("%s is neither a vCenter 2.5 server nor a vCenter "
- "4.0 server"), conn->uri->server);
- goto cleanup;
- }
+ priv->primary = priv->vCenter;
}
conn->privateData = priv;
@@ -604,12 +675,7 @@ esxOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags ATTRIBUTE_UNUSED)
}
esxUtil_FreeParsedQuery(&parsedQuery);
- VIR_FREE(url);
- VIR_FREE(vCenter);
- VIR_FREE(password);
- VIR_FREE(username);
- esxVI_String_Free(&propertyNameList);
- esxVI_ObjectContent_Free(&hostSystem);
+ VIR_FREE(potentialVCenterIpAddress);
return result;
}
@@ -622,12 +688,14 @@ esxClose(virConnectPtr conn)
esxPrivate *priv = conn->privateData;
int result = 0;
- if (esxVI_EnsureSession(priv->host) < 0 ||
- esxVI_Logout(priv->host) < 0) {
- result = -1;
- }
+ if (priv->host != NULL) {
+ if (esxVI_EnsureSession(priv->host) < 0 ||
+ esxVI_Logout(priv->host) < 0) {
+ result = -1;
+ }
- esxVI_Context_Free(&priv->host);
+ esxVI_Context_Free(&priv->host);
+ }
if (priv->vCenter != NULL) {
if (esxVI_EnsureSession(priv->vCenter) < 0 ||
@@ -661,6 +729,11 @@ esxSupportsVMotion(esxPrivate *priv)
return priv->supportsVMotion;
}
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ return esxVI_Boolean_False;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return esxVI_Boolean_Undefined;
}
@@ -745,11 +818,11 @@ esxGetVersion(virConnectPtr conn, unsigned long *version)
{
esxPrivate *priv = conn->privateData;
- if (virParseVersionString(priv->host->service->about->version,
+ if (virParseVersionString(priv->primary->service->about->version,
version) < 0) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Could not parse version number from '%s'"),
- priv->host->service->about->version);
+ priv->primary->service->about->version);
return -1;
}
@@ -770,6 +843,13 @@ esxGetHostname(virConnectPtr conn)
const char *domainName = NULL;
char *complete = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve the hostname for a vpx:// connection"));
+ return NULL;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return NULL;
}
@@ -865,6 +945,13 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo)
memset(nodeinfo, 0, sizeof (*nodeinfo));
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Nodeinfo is not available for a vpx:// connection"));
+ return -1;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return -1;
}
@@ -1034,13 +1121,13 @@ esxListDomains(virConnectPtr conn, int *ids, int maxids)
return 0;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupObjectContentByType(priv->host, priv->host->vmFolder,
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True,
&virtualMachineList) < 0) {
@@ -1090,12 +1177,12 @@ esxNumberOfDomains(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
return esxVI_LookupNumberOfDomainsByPowerState
- (priv->host, esxVI_VirtualMachinePowerState_PoweredOn,
+ (priv->primary, esxVI_VirtualMachinePowerState_PoweredOn,
esxVI_Boolean_False);
}
@@ -1114,7 +1201,7 @@ esxDomainLookupByID(virConnectPtr conn, int id)
unsigned char uuid_candidate[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
@@ -1123,7 +1210,7 @@ esxDomainLookupByID(virConnectPtr conn, int id)
"name\0"
"runtime.powerState\0"
"config.uuid\0") < 0 ||
- esxVI_LookupObjectContentByType(priv->host, priv->host->vmFolder,
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True,
&virtualMachineList) < 0) {
@@ -1190,14 +1277,14 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
char *name = NULL;
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
"runtime.powerState\0") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, uuid, propertyNameList,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, uuid, propertyNameList,
&virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachineIdentity(virtualMachine, &id, &name, NULL) < 0 ||
@@ -1239,7 +1326,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
unsigned char uuid[VIR_UUID_BUFLEN];
virDomainPtr domain = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
@@ -1247,7 +1334,7 @@ esxDomainLookupByName(virConnectPtr conn, const char *name)
"configStatus\0"
"runtime.powerState\0"
"config.uuid\0") < 0 ||
- esxVI_LookupVirtualMachineByName(priv->host, name, propertyNameList,
+ esxVI_LookupVirtualMachineByName(priv->primary, name, propertyNameList,
&virtualMachine,
esxVI_Occurrence_OptionalItem) < 0) {
goto cleanup;
@@ -1297,14 +1384,14 @@ esxDomainSuspend(virDomainPtr domain)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, propertyNameList, &virtualMachine,
+ (priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
@@ -1316,8 +1403,8 @@ esxDomainSuspend(virDomainPtr domain)
goto cleanup;
}
- if (esxVI_SuspendVM_Task(priv->host, virtualMachine->obj, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ if (esxVI_SuspendVM_Task(priv->primary, virtualMachine->obj, &task) < 0 ||
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -1350,14 +1437,14 @@ esxDomainResume(virDomainPtr domain)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, propertyNameList, &virtualMachine,
+ (priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
goto cleanup;
@@ -1368,9 +1455,9 @@ esxDomainResume(virDomainPtr domain)
goto cleanup;
}
- if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, NULL,
+ if (esxVI_PowerOnVM_Task(priv->primary, virtualMachine->obj, NULL,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -1401,13 +1488,13 @@ esxDomainShutdown(virDomainPtr domain)
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
@@ -1420,7 +1507,7 @@ esxDomainShutdown(virDomainPtr domain)
goto cleanup;
}
- if (esxVI_ShutdownGuest(priv->host, virtualMachine->obj) < 0) {
+ if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0) {
goto cleanup;
}
@@ -1444,13 +1531,13 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
@@ -1463,7 +1550,7 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags ATTRIBUTE_UNUSED)
goto cleanup;
}
- if (esxVI_RebootGuest(priv->host, virtualMachine->obj) < 0) {
+ if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0) {
goto cleanup;
}
@@ -1562,13 +1649,13 @@ esxDomainGetMaxMemory(virDomainPtr domain)
esxVI_DynamicProperty *dynamicProperty = NULL;
unsigned long memoryMB = 0;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return 0;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.hardware.memoryMB") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -1615,12 +1702,12 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_Long_Alloc(&spec->memoryMB) < 0) {
@@ -1630,9 +1717,9 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory)
spec->memoryMB->value =
memory / 1024; /* Scale from kilobytes to megabytes */
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -1665,12 +1752,12 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
esxVI_ManagedObjectReference *task = NULL;
esxVI_TaskInfoState taskInfoState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0 ||
@@ -1681,9 +1768,9 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory)
spec->memoryAllocation->limit->value =
memory / 1024; /* Scale from kilobytes to megabytes */
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -1731,7 +1818,7 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
memset(info, 0, sizeof (*info));
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
@@ -1740,7 +1827,7 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
"config.hardware.memoryMB\0"
"config.hardware.numCPU\0"
"config.memoryAllocation.limit\0") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -1793,157 +1880,160 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
info->memory = memory_limit < 0 ? info->maxMem : memory_limit;
/* Verify the cached 'used CPU time' performance counter ID */
- if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
- if (esxVI_Int_Alloc(&counterId) < 0) {
- goto cleanup;
- }
+ /* FIXME: Currently no host for a vpx:// connection */
+ if (priv->host != NULL) {
+ if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
+ if (esxVI_Int_Alloc(&counterId) < 0) {
+ goto cleanup;
+ }
- counterId->value = priv->usedCpuTimeCounterId;
+ counterId->value = priv->usedCpuTimeCounterId;
- if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
- goto cleanup;
- }
+ if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ goto cleanup;
+ }
- if (esxVI_QueryPerfCounter(priv->host, counterIdList,
- &perfCounterInfo) < 0) {
- goto cleanup;
- }
+ if (esxVI_QueryPerfCounter(priv->host, counterIdList,
+ &perfCounterInfo) < 0) {
+ goto cleanup;
+ }
- if (STRNEQ(perfCounterInfo->groupInfo->key, "cpu") ||
- STRNEQ(perfCounterInfo->nameInfo->key, "used") ||
- STRNEQ(perfCounterInfo->unitInfo->key, "millisecond")) {
- VIR_DEBUG("Cached usedCpuTimeCounterId %d is invalid",
- priv->usedCpuTimeCounterId);
+ if (STRNEQ(perfCounterInfo->groupInfo->key, "cpu") ||
+ STRNEQ(perfCounterInfo->nameInfo->key, "used") ||
+ STRNEQ(perfCounterInfo->unitInfo->key, "millisecond")) {
+ VIR_DEBUG("Cached usedCpuTimeCounterId %d is invalid",
+ priv->usedCpuTimeCounterId);
- priv->usedCpuTimeCounterId = -1;
+ priv->usedCpuTimeCounterId = -1;
+ }
+
+ esxVI_Int_Free(&counterIdList);
+ esxVI_PerfCounterInfo_Free(&perfCounterInfo);
}
- esxVI_Int_Free(&counterIdList);
- esxVI_PerfCounterInfo_Free(&perfCounterInfo);
- }
+ /*
+ * Query the PerformanceManager for the 'used CPU time' performance
+ * counter ID and cache it, if it's not already cached.
+ */
+ if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId < 0) {
+ if (esxVI_QueryAvailablePerfMetric(priv->host, virtualMachine->obj,
+ NULL, NULL, NULL,
+ &perfMetricIdList) < 0) {
+ goto cleanup;
+ }
- /*
- * Query the PerformanceManager for the 'used CPU time' performance
- * counter ID and cache it, if it's not already cached.
- */
- if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId < 0) {
- if (esxVI_QueryAvailablePerfMetric(priv->host, virtualMachine->obj,
- NULL, NULL, NULL,
- &perfMetricIdList) < 0) {
- goto cleanup;
- }
+ for (perfMetricId = perfMetricIdList; perfMetricId != NULL;
+ perfMetricId = perfMetricId->_next) {
+ VIR_DEBUG("perfMetricId counterId %d, instance '%s'",
+ perfMetricId->counterId->value, perfMetricId->instance);
- for (perfMetricId = perfMetricIdList; perfMetricId != NULL;
- perfMetricId = perfMetricId->_next) {
- VIR_DEBUG("perfMetricId counterId %d, instance '%s'",
- perfMetricId->counterId->value, perfMetricId->instance);
+ counterId = NULL;
- counterId = NULL;
+ if (esxVI_Int_DeepCopy(&counterId, perfMetricId->counterId) < 0 ||
+ esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ goto cleanup;
+ }
+ }
- if (esxVI_Int_DeepCopy(&counterId, perfMetricId->counterId) < 0 ||
- esxVI_Int_AppendToList(&counterIdList, counterId) < 0) {
+ if (esxVI_QueryPerfCounter(priv->host, counterIdList,
+ &perfCounterInfoList) < 0) {
goto cleanup;
}
- }
- if (esxVI_QueryPerfCounter(priv->host, counterIdList,
- &perfCounterInfoList) < 0) {
- goto cleanup;
- }
-
- for (perfCounterInfo = perfCounterInfoList; perfCounterInfo != NULL;
- perfCounterInfo = perfCounterInfo->_next) {
- VIR_DEBUG("perfCounterInfo key %d, nameInfo '%s', groupInfo '%s', "
- "unitInfo '%s', rollupType %d, statsType %d",
- perfCounterInfo->key->value,
- perfCounterInfo->nameInfo->key,
- perfCounterInfo->groupInfo->key,
- perfCounterInfo->unitInfo->key,
- perfCounterInfo->rollupType,
- perfCounterInfo->statsType);
-
- if (STREQ(perfCounterInfo->groupInfo->key, "cpu") &&
- STREQ(perfCounterInfo->nameInfo->key, "used") &&
- STREQ(perfCounterInfo->unitInfo->key, "millisecond")) {
- priv->usedCpuTimeCounterId = perfCounterInfo->key->value;
- break;
+ for (perfCounterInfo = perfCounterInfoList; perfCounterInfo != NULL;
+ perfCounterInfo = perfCounterInfo->_next) {
+ VIR_DEBUG("perfCounterInfo key %d, nameInfo '%s', groupInfo '%s', "
+ "unitInfo '%s', rollupType %d, statsType %d",
+ perfCounterInfo->key->value,
+ perfCounterInfo->nameInfo->key,
+ perfCounterInfo->groupInfo->key,
+ perfCounterInfo->unitInfo->key,
+ perfCounterInfo->rollupType,
+ perfCounterInfo->statsType);
+
+ if (STREQ(perfCounterInfo->groupInfo->key, "cpu") &&
+ STREQ(perfCounterInfo->nameInfo->key, "used") &&
+ STREQ(perfCounterInfo->unitInfo->key, "millisecond")) {
+ priv->usedCpuTimeCounterId = perfCounterInfo->key->value;
+ break;
+ }
}
- }
- if (priv->usedCpuTimeCounterId < 0) {
- VIR_WARN0("Could not find 'used CPU time' performance counter");
+ if (priv->usedCpuTimeCounterId < 0) {
+ VIR_WARN0("Could not find 'used CPU time' performance counter");
+ }
}
- }
-
- /*
- * Query the PerformanceManager for the 'used CPU time' performance
- * counter value.
- */
- if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
- VIR_DEBUG("usedCpuTimeCounterId %d BEGIN", priv->usedCpuTimeCounterId);
- if (esxVI_PerfQuerySpec_Alloc(&querySpec) < 0 ||
- esxVI_Int_Alloc(&querySpec->maxSample) < 0 ||
- esxVI_PerfMetricId_Alloc(&querySpec->metricId) < 0 ||
- esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0) {
- goto cleanup;
- }
+ /*
+ * Query the PerformanceManager for the 'used CPU time' performance
+ * counter value.
+ */
+ if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) {
+ VIR_DEBUG("usedCpuTimeCounterId %d BEGIN", priv->usedCpuTimeCounterId);
- querySpec->entity = virtualMachine->obj;
- querySpec->maxSample->value = 1;
- querySpec->metricId->counterId->value = priv->usedCpuTimeCounterId;
- querySpec->metricId->instance = (char *)"";
- querySpec->format = (char *)"normal";
+ if (esxVI_PerfQuerySpec_Alloc(&querySpec) < 0 ||
+ esxVI_Int_Alloc(&querySpec->maxSample) < 0 ||
+ esxVI_PerfMetricId_Alloc(&querySpec->metricId) < 0 ||
+ esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0) {
+ goto cleanup;
+ }
- if (esxVI_QueryPerf(priv->host, querySpec,
- &perfEntityMetricBaseList) < 0) {
- querySpec->entity = NULL;
- querySpec->metricId->instance = NULL;
- querySpec->format = NULL;
- goto cleanup;
- }
+ querySpec->entity = virtualMachine->obj;
+ querySpec->maxSample->value = 1;
+ querySpec->metricId->counterId->value = priv->usedCpuTimeCounterId;
+ querySpec->metricId->instance = (char *)"";
+ querySpec->format = (char *)"normal";
+
+ if (esxVI_QueryPerf(priv->host, querySpec,
+ &perfEntityMetricBaseList) < 0) {
+ querySpec->entity = NULL;
+ querySpec->metricId->instance = NULL;
+ querySpec->format = NULL;
+ goto cleanup;
+ }
- for (perfEntityMetricBase = perfEntityMetricBaseList;
- perfEntityMetricBase != NULL;
- perfEntityMetricBase = perfEntityMetricBase->_next) {
- VIR_DEBUG0("perfEntityMetric ...");
+ for (perfEntityMetricBase = perfEntityMetricBaseList;
+ perfEntityMetricBase != NULL;
+ perfEntityMetricBase = perfEntityMetricBase->_next) {
+ VIR_DEBUG0("perfEntityMetric ...");
- perfEntityMetric =
- esxVI_PerfEntityMetric_DynamicCast(perfEntityMetricBase);
+ perfEntityMetric =
+ esxVI_PerfEntityMetric_DynamicCast(perfEntityMetricBase);
- if (perfMetricIntSeries == NULL) {
- VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
- }
+ if (perfMetricIntSeries == NULL) {
+ VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
+ }
- perfMetricIntSeries =
- esxVI_PerfMetricIntSeries_DynamicCast(perfEntityMetric->value);
+ perfMetricIntSeries =
+ esxVI_PerfMetricIntSeries_DynamicCast(perfEntityMetric->value);
- if (perfMetricIntSeries == NULL) {
- VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
- }
+ if (perfMetricIntSeries == NULL) {
+ VIR_ERROR0(_("QueryPerf returned object with unexpected type"));
+ }
- for (; perfMetricIntSeries != NULL;
- perfMetricIntSeries = perfMetricIntSeries->_next) {
- VIR_DEBUG0("perfMetricIntSeries ...");
+ for (; perfMetricIntSeries != NULL;
+ perfMetricIntSeries = perfMetricIntSeries->_next) {
+ VIR_DEBUG0("perfMetricIntSeries ...");
- for (value = perfMetricIntSeries->value;
- value != NULL;
- value = value->_next) {
- VIR_DEBUG("value %lld", (long long int)value->value);
+ for (value = perfMetricIntSeries->value;
+ value != NULL;
+ value = value->_next) {
+ VIR_DEBUG("value %lld", (long long int)value->value);
+ }
}
}
- }
- querySpec->entity = NULL;
- querySpec->metricId->instance = NULL;
- querySpec->format = NULL;
+ querySpec->entity = NULL;
+ querySpec->metricId->instance = NULL;
+ querySpec->format = NULL;
- VIR_DEBUG("usedCpuTimeCounterId %d END", priv->usedCpuTimeCounterId);
+ VIR_DEBUG("usedCpuTimeCounterId %d END", priv->usedCpuTimeCounterId);
- /*
- * FIXME: Cannot map between realtive used-cpu-time and absolute
- * info->cpuTime
- */
+ /*
+ * FIXME: Cannot map between realtive used-cpu-time and absolute
+ * info->cpuTime
+ */
+ }
}
result = 0;
@@ -1979,7 +2069,7 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
return -1;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
@@ -1998,7 +2088,7 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_Int_Alloc(&spec->numCPUs) < 0) {
@@ -2007,9 +2097,9 @@ esxDomainSetVcpus(virDomainPtr domain, unsigned int nvcpus)
spec->numCPUs->value = nvcpus;
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -2046,6 +2136,13 @@ esxDomainGetMaxVcpus(virDomainPtr domain)
priv->maxVcpus = -1;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("MaxVCPUs value is not available for a vpx:// connection"));
+ return -1;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return -1;
}
@@ -2093,9 +2190,11 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
{
esxPrivate *priv = domain->conn->privateData;
esxVI_String *propertyNameList = NULL;
+ esxVI_ObjectContent *datacenter = NULL;
esxVI_ObjectContent *virtualMachine = NULL;
esxVI_DynamicProperty *dynamicProperty = NULL;
const char *vmPathName = NULL;
+ char *datacenterName = NULL;
char *datastoreName = NULL;
char *directoryName = NULL;
char *fileName = NULL;
@@ -2105,13 +2204,24 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
virDomainDefPtr def = NULL;
char *xml = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
+ if (esxVI_String_AppendValueToList(&propertyNameList, "name") < 0 ||
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->datacenter,
+ "Datacenter", propertyNameList,
+ esxVI_Boolean_False, &datacenter) < 0 ||
+ esxVI_GetStringValue(datacenter, "name", &datacenterName,
+ esxVI_Occurrence_RequiredItem) < 0) {
+ goto cleanup;
+ }
+
+ esxVI_String_Free(&propertyNameList);
+
if (esxVI_String_AppendValueToList(&propertyNameList,
"config.files.vmPathName") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -2145,7 +2255,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
virBufferURIEncodeString(&buffer, fileName);
virBufferAddLit(&buffer, "?dcPath=");
- virBufferURIEncodeString(&buffer, priv->host->datacenter->value);
+ virBufferURIEncodeString(&buffer, datacenterName);
virBufferAddLit(&buffer, "&dsName=");
virBufferURIEncodeString(&buffer, datastoreName);
@@ -2156,12 +2266,12 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
url = virBufferContentAndReset(&buffer);
- if (esxVI_Context_DownloadFile(priv->host, url, &vmx) < 0) {
+ if (esxVI_Context_DownloadFile(priv->primary, url, &vmx) < 0) {
goto cleanup;
}
- def = esxVMX_ParseConfig(priv->host, priv->caps, vmx, datastoreName,
- directoryName, priv->host->productVersion);
+ def = esxVMX_ParseConfig(priv->primary, priv->caps, vmx, datastoreName,
+ directoryName, priv->primary->productVersion);
if (def != NULL) {
xml = virDomainDefFormat(def, flags);
@@ -2173,6 +2283,7 @@ esxDomainDumpXML(virDomainPtr domain, int flags)
}
esxVI_String_Free(&propertyNameList);
+ esxVI_ObjectContent_Free(&datacenter);
esxVI_ObjectContent_Free(&virtualMachine);
VIR_FREE(datastoreName);
VIR_FREE(directoryName);
@@ -2201,8 +2312,8 @@ esxDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat,
return NULL;
}
- def = esxVMX_ParseConfig(priv->host, priv->caps, nativeConfig, "?", "?",
- priv->host->productVersion);
+ def = esxVMX_ParseConfig(priv->primary, priv->caps, nativeConfig, "?", "?",
+ priv->primary->productVersion);
if (def != NULL) {
xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE);
@@ -2236,8 +2347,8 @@ esxDomainXMLToNative(virConnectPtr conn, const char *nativeFormat,
return NULL;
}
- vmx = esxVMX_FormatConfig(priv->host, priv->caps, def,
- priv->host->productVersion);
+ vmx = esxVMX_FormatConfig(priv->primary, priv->caps, def,
+ priv->primary->productVersion);
virDomainDefFree(def);
@@ -2268,14 +2379,14 @@ esxListDefinedDomains(virConnectPtr conn, char **const names, int maxnames)
return 0;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueListToList(&propertyNameList,
"name\0"
"runtime.powerState\0") < 0 ||
- esxVI_LookupObjectContentByType(priv->host, priv->host->vmFolder,
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->vmFolder,
"VirtualMachine", propertyNameList,
esxVI_Boolean_True,
&virtualMachineList) < 0) {
@@ -2343,12 +2454,12 @@ esxNumberOfDefinedDomains(virConnectPtr conn)
{
esxPrivate *priv = conn->privateData;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
return esxVI_LookupNumberOfDomainsByPowerState
- (priv->host, esxVI_VirtualMachinePowerState_PoweredOn,
+ (priv->primary, esxVI_VirtualMachinePowerState_PoweredOn,
esxVI_Boolean_True);
}
@@ -2367,14 +2478,14 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, propertyNameList, &virtualMachine,
+ (priv->primary, domain->uuid, propertyNameList, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine,
&powerState) < 0) {
@@ -2387,9 +2498,9 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags)
goto cleanup;
}
- if (esxVI_PowerOnVM_Task(priv->host, virtualMachine->obj, NULL,
+ if (esxVI_PowerOnVM_Task(priv->primary, virtualMachine->obj, NULL,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -2437,6 +2548,13 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml ATTRIBUTE_UNUSED)
esxVI_TaskInfoState taskInfoState;
virDomainPtr domain = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not define domain with a vpx:// connection"));
+ return NULL;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return NULL;
}
@@ -2737,7 +2855,7 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
return -1;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
@@ -2745,7 +2863,7 @@ esxDomainGetSchedulerParameters(virDomainPtr domain,
"config.cpuAllocation.reservation\0"
"config.cpuAllocation.limit\0"
"config.cpuAllocation.shares\0") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0) {
goto cleanup;
@@ -2856,12 +2974,12 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
esxVI_TaskInfoState taskInfoState;
int i;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 ||
esxVI_ResourceAllocationInfo_Alloc(&spec->cpuAllocation) < 0) {
@@ -2944,9 +3062,9 @@ esxDomainSetSchedulerParameters(virDomainPtr domain,
}
}
- if (esxVI_ReconfigVM_Task(priv->host, virtualMachine->obj, spec,
+ if (esxVI_ReconfigVM_Task(priv->primary, virtualMachine->obj, spec,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -3152,6 +3270,13 @@ esxNodeGetFreeMemory(virConnectPtr conn)
esxVI_DynamicProperty *dynamicProperty = NULL;
esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage = NULL;
+ if (priv->host == NULL) {
+ /* FIXME: Currently no host for a vpx:// connection */
+ ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("Could not retrieve free memory for a vpx:// connection"));
+ return 0;
+ }
+
if (esxVI_EnsureSession(priv->host) < 0) {
return 0;
}
@@ -3251,13 +3376,13 @@ esxDomainIsActive(virDomainPtr domain)
esxVI_String *propertyNameList = NULL;
esxVI_VirtualMachinePowerState powerState;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"runtime.powerState") < 0 ||
- esxVI_LookupVirtualMachineByUuid(priv->host, domain->uuid,
+ esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid,
propertyNameList, &virtualMachine,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) {
@@ -3304,7 +3429,7 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
@@ -3315,9 +3440,9 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
}
if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask
- (priv->host, domain->uuid, NULL, &virtualMachine,
+ (priv->primary, domain->uuid, NULL, &virtualMachine,
priv->autoAnswer) < 0 ||
- esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name,
&snapshotTree, &snapshotTreeParent,
@@ -3331,11 +3456,11 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc,
goto cleanup;
}
- if (esxVI_CreateSnapshot_Task(priv->host, virtualMachine->obj,
+ if (esxVI_CreateSnapshot_Task(priv->primary, virtualMachine->obj,
def->name, def->description,
esxVI_Boolean_True,
esxVI_Boolean_False, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -3374,11 +3499,11 @@ esxDomainSnapshotDumpXML(virDomainSnapshotPtr snapshot,
memset(&def, 0, sizeof (def));
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
@@ -3419,11 +3544,11 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0) {
return -1;
}
@@ -3456,11 +3581,11 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen,
return 0;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0) {
return -1;
}
@@ -3486,11 +3611,11 @@ esxDomainSnapshotLookupByName(virDomainPtr domain, const char *name,
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid,
&rootSnapshotTreeList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, name, &snapshotTree,
&snapshotTreeParent,
@@ -3516,11 +3641,11 @@ esxDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupCurrentSnapshotTree(priv->host, domain->uuid,
+ if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
esxVI_Occurrence_OptionalItem) < 0) {
return -1;
@@ -3545,11 +3670,11 @@ esxDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags)
virCheckFlags(0, NULL);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
- if (esxVI_LookupCurrentSnapshotTree(priv->host, domain->uuid,
+ if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid,
¤tSnapshotTree,
esxVI_Occurrence_RequiredItem) < 0) {
return NULL;
@@ -3577,11 +3702,11 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
@@ -3589,9 +3714,9 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags)
goto cleanup;
}
- if (esxVI_RevertToSnapshot_Task(priv->host, snapshotTree->snapshot, NULL,
+ if (esxVI_RevertToSnapshot_Task(priv->primary, snapshotTree->snapshot, NULL,
&task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, snapshot->domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
@@ -3627,7 +3752,7 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
@@ -3635,7 +3760,7 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
removeChildren = esxVI_Boolean_True;
}
- if (esxVI_LookupRootSnapshotTreeList(priv->host, snapshot->domain->uuid,
+ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid,
&rootSnapshotList) < 0 ||
esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name,
&snapshotTree, &snapshotTreeParent,
@@ -3643,9 +3768,9 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags)
goto cleanup;
}
- if (esxVI_RemoveSnapshot_Task(priv->host, snapshotTree->snapshot,
+ if (esxVI_RemoveSnapshot_Task(priv->primary, snapshotTree->snapshot,
removeChildren, &task) < 0 ||
- esxVI_WaitForTaskCompletion(priv->host, task, snapshot->domain->uuid,
+ esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid,
priv->autoAnswer, &taskInfoState) < 0) {
goto cleanup;
}
diff --git a/src/esx/esx_private.h b/src/esx/esx_private.h
index 19955a5..6c7edb1 100644
--- a/src/esx/esx_private.h
+++ b/src/esx/esx_private.h
@@ -33,6 +33,7 @@
__LINE__, __VA_ARGS__)
typedef struct _esxPrivate {
+ esxVI_Context *primary; /* points to host or vCenter */
esxVI_Context *host;
esxVI_Context *vCenter;
virCapsPtr caps;
diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c
index 98e7137..44d7d85 100644
--- a/src/esx/esx_storage_driver.c
+++ b/src/esx/esx_storage_driver.c
@@ -74,11 +74,11 @@ esxNumberOfStoragePools(virConnectPtr conn)
esxVI_ObjectContent *datastoreList = NULL;
esxVI_ObjectContent *datastore = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupObjectContentByType(priv->host, priv->host->datacenter,
+ if (esxVI_LookupObjectContentByType(priv->primary, priv->primary->datacenter,
"Datastore", NULL, esxVI_Boolean_True,
&datastoreList) < 0) {
return -1;
@@ -117,13 +117,13 @@ esxListStoragePools(virConnectPtr conn, char **const names, int maxnames)
return 0;
}
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
if (esxVI_String_AppendValueToList(&propertyNameList,
"summary.name") < 0 ||
- esxVI_LookupObjectContentByType(priv->host, priv->host->datacenter,
+ esxVI_LookupObjectContentByType(priv->primary, priv->primary->datacenter,
"Datastore", propertyNameList,
esxVI_Boolean_True,
&datastoreList) < 0) {
@@ -209,7 +209,7 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
char *realName = NULL;
virStoragePoolPtr pool = NULL;
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
@@ -217,7 +217,7 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
"summary.accessible\0"
"summary.name\0"
"summary.url\0") < 0 ||
- esxVI_LookupDatastoreByName(priv->host, name,
+ esxVI_LookupDatastoreByName(priv->primary, name,
propertyNameList, &datastore,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetBoolean(datastore, "summary.accessible",
@@ -242,7 +242,8 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name)
*
* The 'summary.url' property of an inaccessible datastore is invalid.
*/
- if (accessible == esxVI_Boolean_True &&
+ /* FIXME: Need to handle this for a vpx:// connection */
+ if (accessible == esxVI_Boolean_True && priv->host != NULL &&
priv->host->productVersion & esxVI_ProductVersion_ESX) {
if (esxVI_GetStringValue(datastore, "summary.url", &summaryUrl,
esxVI_Occurrence_RequiredItem) < 0) {
@@ -307,7 +308,9 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
char *name = NULL;
virStoragePoolPtr pool = NULL;
- if (! (priv->host->productVersion & esxVI_ProductVersion_ESX)) {
+ /* FIXME: Need to handle this for a vpx:// connection */
+ if (priv->host == NULL ||
+ ! (priv->host->productVersion & esxVI_ProductVersion_ESX)) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR, "%s",
_("Lookup by UUID is supported on ESX only"));
return NULL;
@@ -389,13 +392,13 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags)
virCheckFlags(0, -1);
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
- if (esxVI_LookupDatastoreByName(priv->host, pool->name, NULL, &datastore,
+ if (esxVI_LookupDatastoreByName(priv->primary, pool->name, NULL, &datastore,
esxVI_Occurrence_RequiredItem) < 0 ||
- esxVI_RefreshDatastore(priv->host, datastore->obj) < 0) {
+ esxVI_RefreshDatastore(priv->primary, datastore->obj) < 0) {
goto cleanup;
}
@@ -421,7 +424,7 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info)
memset(info, 0, sizeof (*info));
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return -1;
}
@@ -429,7 +432,7 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info)
"summary.accessible\0"
"summary.capacity\0"
"summary.freeSpace\0") < 0 ||
- esxVI_LookupDatastoreByName(priv->host, pool->name,
+ esxVI_LookupDatastoreByName(priv->primary, pool->name,
propertyNameList, &datastore,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetBoolean(datastore, "summary.accessible",
@@ -494,7 +497,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
memset(&def, 0, sizeof (def));
- if (esxVI_EnsureSession(priv->host) < 0) {
+ if (esxVI_EnsureSession(priv->primary) < 0) {
return NULL;
}
@@ -503,7 +506,7 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags)
"summary.capacity\0"
"summary.freeSpace\0"
"info\0") < 0 ||
- esxVI_LookupDatastoreByName(priv->host, pool->name,
+ esxVI_LookupDatastoreByName(priv->primary, pool->name,
propertyNameList, &datastore,
esxVI_Occurrence_RequiredItem) < 0 ||
esxVI_GetBoolean(datastore, "summary.accessible",
diff --git a/src/esx/esx_vmx.c b/src/esx/esx_vmx.c
index 9035233..e075149 100644
--- a/src/esx/esx_vmx.c
+++ b/src/esx/esx_vmx.c
@@ -1188,6 +1188,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, virCapsPtr caps, const char *vmx,
*/
switch (productVersion) {
case esxVI_ProductVersion_ESX35:
+ case esxVI_ProductVersion_VPX25:
if (virtualHW_version != 4) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'virtualHW.version' to be 4 "
@@ -1200,6 +1201,7 @@ esxVMX_ParseConfig(esxVI_Context *ctx, virCapsPtr caps, const char *vmx,
case esxVI_ProductVersion_GSX20:
case esxVI_ProductVersion_ESX40:
+ case esxVI_ProductVersion_VPX40:
if (virtualHW_version != 4 && virtualHW_version != 7) {
ESX_ERROR(VIR_ERR_INTERNAL_ERROR,
_("Expecting VMX entry 'virtualHW.version' to be 4 or 7 "
diff --git a/src/libvirt.c b/src/libvirt.c
index d1b210d..3ec5724 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -1224,6 +1224,7 @@ do_open (const char *name,
STRCASEEQ(ret->uri->scheme, "phyp") ||
#endif
#ifndef WITH_ESX
+ STRCASEEQ(ret->uri->scheme, "vpx") ||
STRCASEEQ(ret->uri->scheme, "esx") ||
STRCASEEQ(ret->uri->scheme, "gsx") ||
#endif
--
1.7.0.4
14 years, 3 months
[libvirt] OpenVZ ethernet interface type
by Jean-Baptiste Rouault
Hello,
I'd like to be able to add interfaces to OpenVZ guests like the following
vzctl command does : vzctl set 100 --netif_add eth0,00:11:22:33:44:55,tap0
Here, eth0 is the guest interface name, and tap0 the host interface name.
This is currently not supported by libvirt so I'd like to implement it.
In terms of domain XML I think it would be something like:
<interface type='ethernet'>
<mac address='00:11:22:33:44:55'/>
<source dev='eth0'/>
<target dev='tap0'/>
</interface>
Currently the OpenVZ driver calls "vzctl set 100 --ipadd" when the interface
type is "ethernet" and the ip address attribute isn't empty.
Does it seem ok to use --netif_add for ethernet interfaces when there is no ip
defined ?
Regards,
Jean-Baptiste Rouault
14 years, 3 months
[libvirt] [PATCH] fix handling of PORT_PROFILE_RESPONSE_INPROGRESS netlink message
by Gerhard Stenzel
During function test of the 802.1Qbg implementation in lldpad we came
across a small problem in the handling of the netlink message
corresponding to PORT_PROFILE_RESPONSE_INPROGRESS. This should not
result in returning the default rc=1.
Signed-off-by: Gerhard Stenzel <gerhard.stenzel(a)de.ibm.com>
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 635458d..a6d9a57 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -1025,6 +1025,7 @@ getPortProfileStatus(struct nlattr **tb, int32_t
vf,
if (is8021Qbg) {
/* no in-progress here; may be missing */
*status = PORT_PROFILE_RESPONSE_INPROGRESS;
+ rc = 0;
} else {
msg = _("no IFLA_PORT_RESPONSE found in netlink message");
goto err_exit;
--
Best regards,
Gerhard Stenzel,
-----------------------------------------------------------------------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
14 years, 3 months
[libvirt] [PATCH] maint: fix comment typos
by Eric Blake
* src/network/bridge_driver.c
(networkAddMasqueradingIptablesRules): Fix spelling and grammar.
---
Pushing under the trivial change rule.
src/network/bridge_driver.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 80ed57a..d6c7ae1 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -643,12 +643,12 @@ networkAddMasqueradingIptablesRules(struct network_driver *driver,
*
* We need to end up with 3 rules in the table in this order
*
- * 1. protocol=tcp with sport mapping restricton
- * 2. protocol=udp with sport mapping restricton
+ * 1. protocol=tcp with sport mapping restriction
+ * 2. protocol=udp with sport mapping restriction
* 3. generic any protocol
*
* The sport mappings are required, because default IPtables
- * MASQUERADE is maintain port number unchanged where possible.
+ * MASQUERADE maintain port numbers unchanged where possible.
*
* NFS can be configured to only "trust" port numbers < 1023.
*
--
1.7.2
14 years, 3 months
[libvirt] [PATCH] Introduce a -libvirt-caps flag as a stop-gap
by Anthony Liguori
Today libvirt parses -help output to attempt to enumerate capabilities. This
is very broken and has led to multiple failures. Since libvirt is an important
management interface to QEMU, we need to do a better job giving them the ability
to detect what a QEMU executable supports. Right now, we keep fixing up help
output to appease it's parsing code but this is undesirable.
The Right Solution is to introduce a robust capabilities advertisement that
enumerates every feature we have. As with most Right Solutions, we don't have
mergable code today and it's unclear that we'll get there by the next release.
This patch introduces an incremental solution of just spitting out the handful
of capabilities libvirt is probing for today. This interface will need to
remain forever but can stop being updated once we have a Right Solution.
Signed-off-by: Anthony Liguori <aliguori(a)us.ibm.com>
diff --git a/qemu-options.hx b/qemu-options.hx
index 40cee70..a618914 100644
--- a/qemu-options.hx
+++ b/qemu-options.hx
@@ -2235,7 +2235,26 @@ Normally QEMU loads a configuration file from @var{sysconfdir}/qemu.conf and
option will prevent QEMU from loading these configuration files at startup.
ETEXI
+DEF("libvirt-caps", 0, QEMU_OPTION_libvirt_caps,
+ "-libvirt-caps output libvirt-specific capabilities\n",
+ QEMU_ARCH_ALL)
+STEXI
+@item -libvirt-caps
+@findex -libvirt-caps
+Output a common separate list of capabilities that this version of QEMU
+supports and exit. This interface specifically exists for libvirt's use as an
+intermediate solution until we support a full capabilities system. One this
+capabilities system exist, this option's output should never change.
+
+The format out this command is:
+
+version: VERSION
+package: PACKAGE
+caps: CAP1[,CAP2...]
+ETEXI
+
HXCOMM This is the last statement. Insert new options before this line!
STEXI
@end table
ETEXI
+
diff --git a/vl.c b/vl.c
index ba6ee11..8fe354d 100644
--- a/vl.c
+++ b/vl.c
@@ -2616,6 +2616,14 @@ int main(int argc, char **argv, char **envp)
fclose(fp);
break;
}
+ case QEMU_OPTION_libvirt_caps:
+ printf("version: " QEMU_VERSION "\n"
+ "package: " QEMU_PKGVERSION "\n"
+ "caps: name,enable-kvm,no-reboot,uuid,xen-domid,drive"
+ ",cache-v2,format,vga,serial,mem-path,chardev,balloon"
+ ",device,rtc,netdev,sdl,topology\n");
+ exit(0);
+ break;
default:
os_parse_cmd_args(popt->index, optarg);
}
--
1.7.0.4
14 years, 3 months