[libvirt] [PATCHv4 0/6] API for atomic listing of guests (rest of the series)
by Peter Krempa
This is a respin of patches that have not yet been commited.
Peter Krempa (6):
virsh: Rename namesorter to vshNameSorter and clean up indentation
virsh: add support for virConnectListAllDomains and clean up cmdList
vbox: Add support for virConnectListAllDomains()
hyperv: Add implementation for virConnectListAllDomains()
esx: Add implementation for virConnectListAllDomains()
maint: include ignore-value in internal.h
src/conf/domain_audit.c | 1 -
src/conf/domain_conf.c | 1 -
src/conf/virdomainlist.c | 1 -
src/esx/esx_driver.c | 194 +++++++++++++
src/hyperv/hyperv_driver.c | 136 +++++++++
src/internal.h | 1 +
src/network/bridge_driver.c | 1 -
src/node_device/node_device_hal.c | 1 -
src/openvz/openvz_conf.c | 1 -
src/qemu/qemu_domain.c | 1 -
src/qemu/qemu_monitor_json.c | 1 -
src/util/command.c | 1 -
src/util/event_poll.c | 1 -
src/util/logging.c | 1 -
src/util/memory.c | 1 -
src/util/threadpool.c | 1 -
src/util/virfile.h | 1 -
src/util/virnetdevbandwidth.c | 1 -
src/vbox/vbox_tmpl.c | 170 +++++++++++
src/xenapi/xenapi_driver.c | 1 -
tests/shunloadtest.c | 1 -
tools/virsh.c | 575 +++++++++++++++++++++++++------------
tools/virsh.pod | 92 +++++--
23 files changed, 962 insertions(+), 223 deletions(-)
--
1.7.8.6
12 years, 5 months
[libvirt] Fwd: In Use tracker for network and pci-passthrough devices
by Shradha Shah
This is a conversation that I started with Laine Stump for the implementation of the in-use tracker for network and pci devices.
I want to make this conversation more public in order to receive everyone's view on the topic.
I will also post the responses I got from Laine and Osier Yang.
Many Thanks,
Regards,
Shradha Shah
-------- Original Message --------
Subject: In Use tracker for network and pci-passthrough devices
Date: Tue, 26 Jun 2012 12:23:52 +0100
From: Shradha Shah <sshah(a)solarflare.com>
To: Laine Stump <laine(a)laine.org>
Laine,
I have submitted my v2 patches for forward mode='hostdev' and am planning to work on the in-use tracker for network
and pci-passthrough devices.
I am unable to wrap my head around how I should be implementing this functionality. I am unable to decide at what
level I should be implementing this (network, domain or qemu).
May I ask for your guidance in order to implement this functionality?
--
Many Thanks,
Regards,
Shradha Shah
12 years, 5 months
[libvirt] adding more element to <interface>
by Rashid Zamani
Hello people,
I am considering adding more elements into <interface> name space in order
to support more features of different hypervisors (specificly qemu). I have
discuss this<https://www.redhat.com/archives/libvirt-users/2012-June/msg00141.html>in
user thread, and I have been told to propose an xml syntax for it.
What exactly I have in mind is adding elements like <dns>, <hostname> and
etc. to set the these variables from within the <interface> instead of
having <qemu:commandline> at the end of the file, in case of using qemu. So
the final xml file should look something like below:
<domain type='qemu' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
.
.
.
<interface type='user'>
<mac address=/>
<model type=/>
<bandwidth>
</bandwidth>
<address=/>*
<**hostname=/>
<dns=/>
* .
.
.
</interface>
.
.
.
</domain>
I am wondering, firstly if such a thing is plausible. And if so, how I can
contribute and where I can start from.
Thank you in advance.
Zamani
12 years, 5 months
[libvirt] [libvirt-glib v3 1/2] Make GVirConfigCapabilitiesCpu.get_features virtual
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
Also provide helper function for subclasses that will have the exact
same implementation except that they'll return instances of another type
(subclasses of GVirConfigDomainCpuFeature rather than
GVirConfigDomainCpuFeature itself).
---
libvirt-gconfig/Makefile.am | 1 +
.../libvirt-gconfig-capabilities-cpu-private.h | 35 ++++++++++++++++
libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c | 42 +++++++++++++++-----
libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h | 4 +-
libvirt-gconfig/libvirt-gconfig-private.h | 1 +
5 files changed, 71 insertions(+), 12 deletions(-)
create mode 100644 libvirt-gconfig/libvirt-gconfig-capabilities-cpu-private.h
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index 7f0ea3b..52f2d52 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -73,6 +73,7 @@ GCONFIG_HEADER_FILES = \
libvirt-gconfig-storage-vol-target.h
noinst_HEADERS = \
libvirt-gconfig-private.h \
+ libvirt-gconfig-capabilities-cpu-private.h \
libvirt-gconfig-domain-device-private.h \
libvirt-gconfig-helpers-private.h \
libvirt-gconfig-object-private.h \
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-private.h b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-private.h
new file mode 100644
index 0000000..4832656
--- /dev/null
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu-private.h
@@ -0,0 +1,35 @@
+/*
+ * libvirt-gconfig-capabilities-cpu-private.h: libvirt CPU capabilities
+ *
+ * Copyright (C) 2012 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak(a)gnome.org>
+ */
+#ifndef __LIBVIRT_GCONFIG_CAPABILITIES_CPU_PRIVATE_H__
+#define __LIBVIRT_GCONFIG_CAPABILITIES_CPU_PRIVATE_H__
+
+G_BEGIN_DECLS
+
+#include <libvirt-gconfig/libvirt-gconfig.h>
+
+GList *
+gvir_config_capabilities_cpu_get_features_with_type(GVirConfigCapabilitiesCpu *cpu,
+ GType type);
+
+G_END_DECLS
+
+#endif /* __LIBVIRT_GCONFIG_CAPABILITIES_CPU_PRIVATE_H__ */
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
index e517a20..5b619b5 100644
--- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.c
@@ -37,10 +37,14 @@ struct _GVirConfigCapabilitiesCpuPrivate
G_DEFINE_TYPE(GVirConfigCapabilitiesCpu, gvir_config_capabilities_cpu, GVIR_CONFIG_TYPE_OBJECT);
+static GList *
+_gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *cpu);
static void gvir_config_capabilities_cpu_class_init(GVirConfigCapabilitiesCpuClass *klass)
{
g_type_class_add_private(klass, sizeof(GVirConfigCapabilitiesCpuPrivate));
+
+ klass->get_features = _gvir_config_capabilities_cpu_get_features;
}
static void gvir_config_capabilities_cpu_init(GVirConfigCapabilitiesCpu *cpu)
@@ -75,6 +79,7 @@ struct GetFeatureData {
GVirConfigXmlDoc *doc;
const gchar *schema;
GList *features;
+ GType type;
};
static gboolean add_feature(xmlNodePtr node, gpointer opaque)
@@ -86,7 +91,7 @@ static gboolean add_feature(xmlNodePtr node, gpointer opaque)
return TRUE;
feature = gvir_config_object_new_from_tree
- (GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE,
+ (data->type,
data->doc,
data->schema,
node);
@@ -98,16 +103,9 @@ static gboolean add_feature(xmlNodePtr node, gpointer opaque)
return TRUE;
}
-/**
- * gvir_config_capabilities_cpu_get_features:
- *
- * Gets the features of this CPU.
- *
- * Returns: (element-type LibvirtGConfig.CapabilitiesCpuFeature) (transfer full):
- * a newly allocated #GList of #GVirConfigCapabilitiesCpuFeature.
- */
-GList *
-gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *cpu)
+G_GNUC_INTERNAL GList *
+gvir_config_capabilities_cpu_get_features_with_type(GVirConfigCapabilitiesCpu *cpu,
+ GType type)
{
struct GetFeatureData data;
@@ -117,6 +115,7 @@ gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *cpu)
g_object_get(G_OBJECT(cpu), "doc", &data.doc, NULL);
g_return_val_if_fail(data.doc != NULL, NULL);
data.features = NULL;
+ data.type = type;
gvir_config_object_foreach_child(GVIR_CONFIG_OBJECT(cpu),
NULL,
@@ -127,6 +126,27 @@ gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *cpu)
return data.features;
}
+static GList *
+_gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *cpu)
+{
+ return gvir_config_capabilities_cpu_get_features_with_type(
+ cpu, GVIR_CONFIG_TYPE_CAPABILITIES_CPU_FEATURE);
+}
+
+/**
+ * gvir_config_capabilities_cpu_get_features:
+ *
+ * Gets the features of this CPU.
+ *
+ * Returns: (element-type LibvirtGConfig.CapabilitiesCpuFeature) (transfer full):
+ * a newly allocated #GList of #GVirConfigCapabilitiesCpuFeature.
+ */
+GList *
+gvir_config_capabilities_cpu_get_features(GVirConfigCapabilitiesCpu *cpu)
+{
+ return GVIR_CONFIG_CAPABILITIES_CPU_GET_CLASS(cpu)->get_features(cpu);
+}
+
/**
* gvir_config_capabilities_cpu_get_topology:
*
diff --git a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
index 67fe607..be6c06f 100644
--- a/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
+++ b/libvirt-gconfig/libvirt-gconfig-capabilities-cpu.h
@@ -57,7 +57,9 @@ struct _GVirConfigCapabilitiesCpuClass
{
GVirConfigObjectClass parent_class;
- gpointer padding[20];
+ GList *(*get_features)(GVirConfigCapabilitiesCpu *cpu);
+
+ gpointer padding[19];
};
GType gvir_config_capabilities_cpu_get_type(void);
diff --git a/libvirt-gconfig/libvirt-gconfig-private.h b/libvirt-gconfig/libvirt-gconfig-private.h
index d4df030..ea532ad 100644
--- a/libvirt-gconfig/libvirt-gconfig-private.h
+++ b/libvirt-gconfig/libvirt-gconfig-private.h
@@ -23,6 +23,7 @@
#ifndef __LIBVIRT_GCONFIG_PRIVATE_H__
#define __LIBVIRT_GCONFIG_PRIVATE_H__
+#include <libvirt-gconfig/libvirt-gconfig-capabilities-cpu-private.h>
#include <libvirt-gconfig/libvirt-gconfig-domain-device-private.h>
#include <libvirt-gconfig/libvirt-gconfig-helpers-private.h>
#include <libvirt-gconfig/libvirt-gconfig-object-private.h>
--
1.7.10.4
12 years, 5 months
[libvirt] [PATCH] [libvirt-java] Fix JNA passing of scheduler parameters
by Daniel Veillard
trying to use setSchedulerParameters for the cpu_share was always
ending up setting the value to 2. in practice the JNA code was not
passing the parameter value, letting it uninitialized to zero and
the kernel accepts 2 as the closest value leading to that behaviour.
The code was actually telling JNA which type to use from the enum
but the JNA refused to take it into account possibly because multiple
C types maps to the same Java types and in that case it refuses to
accept setType(class) and simply act as if the information had not
been given (no warning/no error at runtime) !
The workaround is to actually tell it the field name in the enum,
that is accepted and the function works properly once done.
diff --git a/src/main/java/org/libvirt/SchedParameter.java b/src/main/java/org/libvirt/SchedParameter.java
index ab988e9..1dece56 100644
--- a/src/main/java/org/libvirt/SchedParameter.java
+++ b/src/main/java/org/libvirt/SchedParameter.java
@@ -52,33 +52,33 @@ public abstract class SchedParameter {
switch (param.getType()) {
case (1):
returnValue.value.i = ((SchedIntParameter) param).value;
- returnValue.value.setType(int.class);
+ returnValue.value.setType("i");
break;
case (2):
returnValue.value.ui = ((SchedUintParameter) param).value;
- returnValue.value.setType(int.class);
+ returnValue.value.setType("ui");
break;
case (3):
returnValue.value.l = ((SchedLongParameter) param).value;
- returnValue.value.setType(long.class);
+ returnValue.value.setType("l");
break;
case (4):
returnValue.value.ul = ((SchedUlongParameter) param).value;
- returnValue.value.setType(long.class);
+ returnValue.value.setType("ul");
break;
case (5):
returnValue.value.d = ((SchedDoubleParameter) param).value;
- returnValue.value.setType(double.class);
+ returnValue.value.setType("d");
break;
case (6):
returnValue.value.b = (byte) (((SchedBooleanParameter) param).value ? 1 : 0);
- returnValue.value.setType(byte.class);
+ returnValue.value.setType("b");
break;
}
return returnValue;
}
-
+
public static byte[] copyOf(byte[] original, int length) {
byte[] returnValue = new byte[length];
int originalLength = original.length ;
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
12 years, 5 months
[libvirt] Coverity automatic detection
by Alex Jia
This email is automatically generated.
The test result is based on the following git commit:
cd15303 events: Don't fail on registering events for two different domains
Analysis summary report:
------------------------
Files analyzed : 314
Total LoC input to cov-analyze : 371998
Functions analyzed : 9054
Paths analyzed : 1066057
Defect occurrences found : 136 Total
7 ATOMICITY
9 CHECKED_RETURN
6 DEADCODE
9 FORWARD_NULL
13 LOCK
5 NEGATIVE_RETURNS
3 NO_EFFECT
2 NULL_RETURNS
1 OVERRUN_STATIC
15 RESOURCE_LEAK
1 RETURN_LOCAL
14 REVERSE_INULL
3 SECURE_TEMP
1 SIZEOF_MISMATCH
1 STRING_NULL
13 TAINTED_SCALAR
3 TAINTED_STRING
18 TOCTOU
10 UNINIT
2 UNUSED_VALUE
Exceeded path limit of 5000 paths in 0.59% of functions (normally up to 5% of functions encounter this limitation)
For details, please see attachment.
Regards,
Alex
12 years, 5 months
[libvirt] [PATCH] storage: Error out if the target is already mounted for netfs pool
by Osier Yang
mnt_fsname can not be the same, as we check the duplicate pool
sources earlier before, means it can't be the same pool, moreover,
a pool can't be started if it's already active anyway. So no reason
to act as success.
---
src/storage/storage_backend_fs.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c
index bde4528..87d9192 100644
--- a/src/storage/storage_backend_fs.c
+++ b/src/storage/storage_backend_fs.c
@@ -424,10 +424,10 @@ virStorageBackendFileSystemMount(virStoragePoolObjPtr pool) {
/* Short-circuit if already mounted */
if ((ret = virStorageBackendFileSystemIsMounted(pool)) != 0) {
- if (ret < 0)
- return -1;
- else
- return 0;
+ virStorageReportError(VIR_ERR_OPERATION_INVALID,
+ _("Target '%s' is already mounted"),
+ pool->def->target.path);
+ return -1;
}
if (pool->def->type == VIR_STORAGE_POOL_NETFS) {
--
1.7.7.3
12 years, 5 months
[libvirt] [PATCH 0/6 v2] Support forward mode='hostdev' and interface pools
by Shradha Shah
This patch series supports the forward mode='hostdev'. The functionality
of this mode is the same as interface type='hostdev' but with the added
benefit of using interface pools.
The patch series also contains a patch to support use of interface names
and PCI device addresses interchangeably in a network xml, and return
the appropriate one in actualDevice when networkAllocateActualDevice is
called.
At the top level managed attribute can be specified with identical results
as when it's specified for a hostdev.
Currently forward mode='hostdev' does not support USB devices.
Shradha Shah (6):
Prerequisite Patch. virDomainDevicePCIAddress and respective
functions moved to a new file called conf/device_conf.ch
Moved the code to create implicit interface pool from PF to a new
function
RNG updates, new xml parser/formatter code to support forward
mode=hostdev
Code to return interface name or pci_addr of the VF in actualDevice
Forward Mode Hostdev network driver Implementation
Forward Mode 'Hostdev' qemu driver implementation
docs/formatnetwork.html.in | 62 ++++++
docs/schemas/network.rng | 82 ++++++++-
src/Makefile.am | 7 +-
src/conf/device_conf.c | 135 +++++++++++++
src/conf/device_conf.h | 65 +++++++
src/conf/domain_conf.c | 114 ++----------
src/conf/domain_conf.h | 25 +---
src/conf/network_conf.c | 126 +++++++++++--
src/conf/network_conf.h | 29 +++-
src/libvirt_private.syms | 10 +-
src/network/bridge_driver.c | 322 +++++++++++++++++++++++++-------
src/qemu/qemu_command.c | 27 ++-
src/qemu/qemu_hotplug.c | 7 +-
src/qemu/qemu_monitor.c | 14 +-
src/qemu/qemu_monitor.h | 17 +-
src/qemu/qemu_monitor_json.c | 14 +-
src/qemu/qemu_monitor_json.h | 14 +-
src/qemu/qemu_monitor_text.c | 16 +-
src/qemu/qemu_monitor_text.h | 14 +-
src/util/virnetdev.c | 29 ++--
src/util/virnetdev.h | 4 +-
src/xen/xend_internal.c | 3 +-
tests/networkxml2xmlin/hostdev-pf.xml | 11 +
tests/networkxml2xmlin/hostdev.xml | 10 +
tests/networkxml2xmlout/hostdev-pf.xml | 7 +
tests/networkxml2xmlout/hostdev.xml | 10 +
tests/networkxml2xmltest.c | 2 +
27 files changed, 889 insertions(+), 287 deletions(-)
create mode 100644 src/conf/device_conf.c
create mode 100644 src/conf/device_conf.h
create mode 100644 tests/networkxml2xmlin/hostdev-pf.xml
create mode 100644 tests/networkxml2xmlin/hostdev.xml
create mode 100644 tests/networkxml2xmlout/hostdev-pf.xml
create mode 100644 tests/networkxml2xmlout/hostdev.xml
--
1.7.4.4
12 years, 5 months
[libvirt] [PATCH] events: Don't fail on registering events for two different domains
by Michal Privoznik
virConnectDomainEventRegisterAny() takes a domain as an argument.
So it should be possible to register the same event (be it
VIR_DOMAIN_EVENT_ID_LIFECYCLE for example) for two different domains.
That is, we need to take domain into account when searching for
duplicate event being already registered.
---
src/conf/domain_event.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/src/conf/domain_event.c b/src/conf/domain_event.c
index 4ecc413..3cfd940 100644
--- a/src/conf/domain_event.c
+++ b/src/conf/domain_event.c
@@ -363,7 +363,11 @@ virDomainEventCallbackListAddID(virConnectPtr conn,
for (i = 0 ; i < cbList->count ; i++) {
if (cbList->callbacks[i]->cb == VIR_DOMAIN_EVENT_CALLBACK(callback) &&
cbList->callbacks[i]->eventID == eventID &&
- cbList->callbacks[i]->conn == conn) {
+ cbList->callbacks[i]->conn == conn &&
+ ((dom && cbList->callbacks[i]->dom &&
+ memcmp(cbList->callbacks[i]->dom->uuid,
+ dom->uuid, VIR_UUID_BUFLEN) == 0) ||
+ (!dom && !cbList->callbacks[i]->dom))) {
eventReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("event callback already tracked"));
return -1;
--
1.7.3.4
12 years, 6 months
[libvirt] [PATCH] virsh: Add domdisplay command for VNC and SPICE
by Doug Goldstein
Add a new 'domdisplay' command that provides a URI for both VNC and
SPICE connections. Presently the 'vncdisplay' command provides you with
the port info that QEMU is listening on but there is no counterpart for
SPICE. Additionally this provides you with the bind address as specified
in the XML, which the existing 'vncdisplay' lacks.
Signed-off-by: Doug Goldstein <cardoe(a)cardoe.com>
---
tools/virsh.c | 128 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 128 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index 4d34d49..88d4681 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -13624,6 +13624,133 @@ cmdSysinfo (vshControl *ctl, const vshCmd
*cmd ATTRIBUTE_UNUSED)
}
/*
+ * "display" command
+ */
+static const vshCmdInfo info_domdisplay[] = {
+ {"help", N_("domain display connection URI")},
+ {"desc", N_("Output the IP address and port number for the
graphical display.")},
+ {NULL, NULL}
+};
+
+static const vshCmdOptDef opts_domdisplay[] = {
+ {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
+ {NULL, 0, 0, NULL}
+};
+
+static bool
+cmdDomDisplay(vshControl *ctl, const vshCmd *cmd)
+{
+ xmlDocPtr xml = NULL;
+ xmlXPathObjectPtr obj = NULL;
+ xmlXPathContextPtr ctxt = NULL;
+ virDomainPtr dom;
+ bool ret = false;
+ int port = 0;
+ char *doc;
+ char *xpath;
+ const char *scheme[] = { "vnc", "spice", NULL };
+ int iter = 0;
+
+ if (!vshConnectionUsability(ctl, ctl->conn))
+ return false;
+
+ if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
+ return false;
+
+ doc = virDomainGetXMLDesc(dom, 0);
+ if (!doc)
+ goto cleanup;
+
+ xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt);
+ VIR_FREE(doc);
+ if (!xml)
+ goto cleanup;
+
+ /* Attempt to grab our display info */
+ for (iter = 0; scheme[iter] != NULL; iter++) {
+ /* Create our XPATH lookup for the current display */
+ virAsprintf(&xpath, "string(/domain/devices/graphics[@type='%s']"
+ "/@port)", scheme[iter]);
+ if (!xpath) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ obj = xmlXPathEval(BAD_CAST xpath, ctxt);
+ VIR_FREE(xpath);
+ if (obj == NULL || obj->type != XPATH_STRING ||
+ obj->stringval == NULL) {
+ if (obj) {
+ /* Clean up memory */
+ xmlXPathFreeObject(obj);
+ obj = NULL;
+ }
+ continue;
+ }
+
+ /* If there was a port number, then the guest uses the
current scheme */
+ if (obj->stringval[0] != 0) {
+
+ /* Make sure this is a valid port number */
+ if (virStrToLong_i((const char *)obj->stringval, NULL,
10, &port)) {
+ vshError(ctl, _("Unable to interpret '%s' as a port number."),
+ obj->stringval);
+ goto cleanup;
+ }
+
+ if (port < 0) {
+ vshError(ctl, _("Invalid port '%d', guest likely not
started."),
+ port);
+ goto cleanup;
+ }
+
+ /* Clean up memory */
+ xmlXPathFreeObject(obj);
+ obj = NULL;
+
+ virAsprintf(&xpath, "string(/domain/devices/graphics[@type='%s']"
+ "/@listen)", scheme[iter]);
+ if (!xpath) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ obj = xmlXPathEval(BAD_CAST xpath, ctxt);
+ VIR_FREE(xpath);
+
+ /* VNC protocol handlers take their port number as X - 5900 */
+ if (scheme[iter] == "vnc")
+ port -= 5900;
+
+ if (obj == NULL || obj->type != XPATH_STRING ||
+ obj->stringval == NULL || obj->stringval[0] == 0 ||
+ STREQ((const char *)obj->stringval, "0.0.0.0")) {
+ vshPrint(ctl, "%s://localhost:%d\n", scheme[iter], port);
+ } else {
+ vshPrint(ctl, "%s://%s:%d\n", scheme[iter],
+ (const char *)obj->stringval, port);
+ }
+
+ /* Clean up memory */
+ xmlXPathFreeObject(obj);
+ obj = NULL;
+
+ /* We got what we came for so return successfully */
+ ret = true;
+ break;
+ }
+
+ }
+
+cleanup:
+ xmlXPathFreeObject(obj);
+ xmlXPathFreeContext(ctxt);
+ xmlFreeDoc(xml);
+ virDomainFree(dom);
+ return ret;
+}
+
+/*
* "vncdisplay" command
*/
static const vshCmdInfo info_vncdisplay[] = {
@@ -17702,6 +17829,7 @@ static const vshCmdDef domManagementCmds[] = {
{"detach-disk", cmdDetachDisk, opts_detach_disk, info_detach_disk, 0},
{"detach-interface", cmdDetachInterface, opts_detach_interface,
info_detach_interface, 0},
+ {"domdisplay", cmdDomDisplay, opts_domdisplay, info_domdisplay, 0},
{"domid", cmdDomid, opts_domid, info_domid, 0},
{"domif-setlink", cmdDomIfSetLink, opts_domif_setlink,
info_domif_setlink, 0},
{"domiftune", cmdDomIftune, opts_domiftune, info_domiftune, 0},
--
1.7.3.4
12 years, 6 months