[libvirt] [PATCH] virsh: Add .xml suffix to tmp files used in *edit commands
by Jiri Denemark
This helps editors with detecting the temporary files as XML since the
temporary files do not contain <?xml ...?> declaration.
Requested by https://bugzilla.redhat.com/show_bug.cgi?id=602277
---
bootstrap.conf | 1 +
tools/virsh.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/bootstrap.conf b/bootstrap.conf
index 8f25554..12f64c8 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -42,6 +42,7 @@ inet_pton
ioctl
maintainer-makefile
mkstemp
+mkstemps
mktempd
netdb
perror
diff --git a/tools/virsh.c b/tools/virsh.c
index bc746f8..26d7f5a 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -8964,10 +8964,10 @@ editWriteToTempFile (vshControl *ctl, const char *doc)
tmpdir = getenv ("TMPDIR");
if (!tmpdir) tmpdir = "/tmp";
- snprintf (ret, PATH_MAX, "%s/virshXXXXXX", tmpdir);
- fd = mkstemp (ret);
+ snprintf (ret, PATH_MAX, "%s/virshXXXXXX.xml", tmpdir);
+ fd = mkstemps(ret, 4);
if (fd == -1) {
- vshError(ctl, _("mkstemp: failed to create temporary file: %s"),
+ vshError(ctl, _("mkstemps: failed to create temporary file: %s"),
strerror(errno));
VIR_FREE(ret);
return NULL;
--
1.7.3.2
13 years, 11 months
[libvirt] [PATCH v4] qemu: call drive_del in DetachPciDiskDevice
by Ryan Harper
Currently libvirt doesn't confirm whether the guest has responded to the
disk removal request. In some cases this can leave the guest with
continued access to the device while the mgmt layer believes that it has
been removed. With a recent qemu monitor command[1] we can
deterministically revoke a guests access to the disk (on the QEMU side)
to ensure no futher access is permitted.
This patch adds support for the drive_del() command and introduces it
in the disk removal paths. If the guest is running in a QEMU without this
command we currently explicitly check for unknown command/CommandNotFound
and log the issue.
If QEMU supports the command we issue the drive_del command after we attempt
to remove the device. The guest may respond and remove the block device
before we get to attempt to call drive_del. In that case, we explicitly check
for 'Device not found' from the monitor indicating that the target drive
was auto-deleted upon guest responds to the device removal notification.
1. http://thread.gmane.org/gmane.comp.emulators.qemu/84255
Signed-off-by: Ryan Harper <ryanh(a)us.ibm.com>
---
Changes since v3:
- Renamed DriveUnplug -> DriveDel, use drive_del monitor cmd.
- Moved invocation to after DelDevice and guest notification.
- Handle the case where drive is auto-deleted before we call
DriveDel by catching and ignoring 'Device not found' error.
- Simplified DriveDel invocation; no need to check return codes
as the monitor implementations handle all failure case and logs
or ignores as needed.
Changes since v2:
- use VIR_ERROR to report when unplug command not found
Changes since v1:
- return > 0 when command isn't present, < 0 on command failure
- detect when drive_unplug command isn't present and log error
instead of failing entire command
src/qemu/qemu_driver.c | 29 ++++++++++++++++++++++
src/qemu/qemu_monitor.c | 19 ++++++++++++++
src/qemu/qemu_monitor.h | 3 ++
src/qemu/qemu_monitor_json.c | 38 +++++++++++++++++++++++++++++
src/qemu/qemu_monitor_json.h | 3 ++
src/qemu/qemu_monitor_text.c | 54 ++++++++++++++++++++++++++++++++++++++++++
src/qemu/qemu_monitor_text.h | 3 ++
7 files changed, 149 insertions(+), 0 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e7b37e1..d01bb2c 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -9037,6 +9037,7 @@ static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver,
virDomainDiskDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
virCgroupPtr cgroup = NULL;
+ char drivestr[PATH_MAX];
i = qemudFindDisk(vm->def, dev->data.disk->dst);
@@ -9077,6 +9078,20 @@ static int qemudDomainDetachPciDiskDevice(struct qemud_driver *driver,
goto cleanup;
}
}
+
+ /* build the actual drive id string as the disk->info.alias doesn't
+ * contain the QEMU_DRIVE_HOST_PREFIX that is passed to qemu */
+ if ((ret = snprintf(drivestr, sizeof(drivestr), "%s%s",
+ QEMU_DRIVE_HOST_PREFIX,
+ detach->info.alias))
+ < 0 || ret >= sizeof(drivestr)) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ /* disconnect guest from host device */
+ qemuMonitorDriveDel(priv->mon, drivestr);
+
qemuDomainObjExitMonitorWithDriver(driver, vm);
qemuDomainDiskAudit(vm, detach, NULL, "detach", ret >= 0);
@@ -9116,6 +9131,7 @@ static int qemudDomainDetachSCSIDiskDevice(struct qemud_driver *driver,
virDomainDiskDefPtr detach = NULL;
qemuDomainObjPrivatePtr priv = vm->privateData;
virCgroupPtr cgroup = NULL;
+ char drivestr[PATH_MAX];
i = qemudFindDisk(vm->def, dev->data.disk->dst);
@@ -9147,6 +9163,19 @@ static int qemudDomainDetachSCSIDiskDevice(struct qemud_driver *driver,
qemuDomainObjExitMonitor(vm);
goto cleanup;
}
+
+ /* build the actual drive id string as the disk->info.alias doesn't
+ * contain the QEMU_DRIVE_HOST_PREFIX that is passed to qemu */
+ if ((ret = snprintf(drivestr, sizeof(drivestr), "%s%s",
+ QEMU_DRIVE_HOST_PREFIX,
+ detach->info.alias))
+ < 0 || ret >= sizeof(drivestr)) {
+ virReportOOMError();
+ goto cleanup;
+ }
+ /* disconnect guest from host device */
+ qemuMonitorDriveDel(priv->mon, drivestr);
+
qemuDomainObjExitMonitorWithDriver(driver, vm);
qemuDomainDiskAudit(vm, detach, NULL, "detach", ret >= 0);
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2366fdb..80adba4 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1781,6 +1781,25 @@ int qemuMonitorGetAllPCIAddresses(qemuMonitorPtr mon,
return ret;
}
+int qemuMonitorDriveDel(qemuMonitorPtr mon,
+ const char *drivestr)
+{
+ DEBUG("mon=%p drivestr=%s", mon, drivestr);
+ int ret;
+
+ if (!mon) {
+ qemuReportError(VIR_ERR_INVALID_ARG, "%s",
+ _("monitor must not be NULL"));
+ return -1;
+ }
+
+ if (mon->json)
+ ret = qemuMonitorJSONDriveDel(mon, drivestr);
+ else
+ ret = qemuMonitorTextDriveDel(mon, drivestr);
+ return ret;
+}
+
int qemuMonitorDelDevice(qemuMonitorPtr mon,
const char *devalias)
{
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 7d09145..8cda43b 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -381,6 +381,9 @@ int qemuMonitorDelDevice(qemuMonitorPtr mon,
int qemuMonitorAddDrive(qemuMonitorPtr mon,
const char *drivestr);
+int qemuMonitorDriveDel(qemuMonitorPtr mon,
+ const char *drivestr);
+
int qemuMonitorSetDrivePassphrase(qemuMonitorPtr mon,
const char *alias,
const char *passphrase);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d2c6f0a..a380ab2 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2244,6 +2244,44 @@ int qemuMonitorJSONAddDrive(qemuMonitorPtr mon,
}
+int qemuMonitorJSONDriveDel(qemuMonitorPtr mon,
+ const char *drivestr)
+{
+ int ret;
+ virJSONValuePtr cmd;
+ virJSONValuePtr reply = NULL;
+
+ DEBUG("JSONDriveDel drivestr=%s", drivestr);
+ cmd = qemuMonitorJSONMakeCommand("drive_del",
+ "s:id", drivestr,
+ NULL);
+ if (!cmd)
+ return -1;
+
+ ret = qemuMonitorJSONCommand(mon, cmd, &reply);
+
+ if (ret == 0) {
+ /* See if drive_del isn't supported */
+ if (qemuMonitorJSONHasError(reply, "CommandNotFound")) {
+ VIR_ERROR0(_("deleting disk is not supported. "
+ "This may leak data if disk is reassigned"));
+ ret = 1;
+ goto cleanup;
+ } else if (qemuMonitorJSONHasError(reply, "DeviceNotFound")) {
+ /* NB: device not found errors mean the drive was
+ * auto-deleted and we ignore the error */
+ ret = 0;
+ } else {
+ ret = qemuMonitorJSONCheckError(cmd, reply);
+ }
+ }
+
+cleanup:
+ virJSONValueFree(cmd);
+ virJSONValueFree(reply);
+ return ret;
+}
+
int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
const char *alias,
const char *passphrase)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 94806c1..82671c7 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -188,6 +188,9 @@ int qemuMonitorJSONDelDevice(qemuMonitorPtr mon,
int qemuMonitorJSONAddDrive(qemuMonitorPtr mon,
const char *drivestr);
+int qemuMonitorJSONDriveDel(qemuMonitorPtr mon,
+ const char *drivestr);
+
int qemuMonitorJSONSetDrivePassphrase(qemuMonitorPtr mon,
const char *alias,
const char *passphrase);
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 7f15008..483ceb0 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -2285,6 +2285,7 @@ int qemuMonitorTextDelDevice(qemuMonitorPtr mon,
goto cleanup;
}
+ DEBUG("TextDelDevice devalias=%s", devalias);
if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
qemuReportError(VIR_ERR_OPERATION_FAILED,
_("cannot detach %s device"), devalias);
@@ -2391,6 +2392,59 @@ cleanup:
return ret;
}
+/* Attempts to remove a host drive.
+ * Returns 1 if unsupported, 0 if ok, and -1 on other failure */
+int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
+ const char *drivestr)
+{
+ char *cmd = NULL;
+ char *reply = NULL;
+ char *safedev;
+ int ret = -1;
+ DEBUG("TextDriveDel drivestr=%s", drivestr);
+
+ if (!(safedev = qemuMonitorEscapeArg(drivestr))) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (virAsprintf(&cmd, "drive_del %s", safedev) < 0) {
+ virReportOOMError();
+ goto cleanup;
+ }
+
+ if (qemuMonitorCommand(mon, cmd, &reply) < 0) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("cannot delete %s drive"), drivestr);
+ goto cleanup;
+ }
+
+ if (strstr(reply, "unknown command:")) {
+ VIR_ERROR0(_("deleting drive is not supported. "
+ "This may leak data if disk is reassigned"));
+ ret = 1;
+ goto cleanup;
+
+ /* (qemu) drive_del wark
+ * Device 'wark' not found */
+ } else if (STRPREFIX(reply, "Device '") && (strstr(reply, "not found"))) {
+ /* NB: device not found errors mean the drive was auto-deleted and we
+ * ignore the error */
+ ret = 0;
+ } else if (STRNEQ(reply, "")) {
+ qemuReportError(VIR_ERR_OPERATION_FAILED,
+ _("deleting %s drive failed: %s"), drivestr, reply);
+ goto cleanup;
+ }
+
+ ret = 0;
+
+cleanup:
+ VIR_FREE(cmd);
+ VIR_FREE(reply);
+ VIR_FREE(safedev);
+ return ret;
+}
int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
const char *alias,
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index c017509..3a88f87 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -186,6 +186,9 @@ int qemuMonitorTextDelDevice(qemuMonitorPtr mon,
int qemuMonitorTextAddDrive(qemuMonitorPtr mon,
const char *drivestr);
+int qemuMonitorTextDriveDel(qemuMonitorPtr mon,
+ const char *drivestr);
+
int qemuMonitorTextSetDrivePassphrase(qemuMonitorPtr mon,
const char *alias,
const char *passphrase);
--
1.6.3.3
--
Ryan Harper
Software Engineer; Linux Technology Center
IBM Corp., Austin, Tx
ryanh(a)us.ibm.com
13 years, 11 months
[libvirt] [PATCH] maint: Commit .gitignore sorting done by bootstrap
by Jiri Denemark
---
.gitignore | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
I pushed this trivial patch.
diff --git a/.gitignore b/.gitignore
index fc3e9d5..a9235b2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,8 +14,8 @@
.sc-start-sc_*
/GNUmakefile
/libvirt-[0-9]*
-/proxy/
/maint.mk
+/proxy/
ABOUT-NLS
COPYING
ChangeLog
--
1.7.3.2
13 years, 11 months
[libvirt] [PATCH] xen-proxy: Remove it entirely and use libvirtd instead
by Matthias Bolte
Suggested by danpb, as it's not up-to-date anymore and
lacks many functions that were added to libvirtd.
---
Makefile.am | 2 +-
autobuild.sh | 3 +-
cfg.mk | 1 -
configure.ac | 26 +-
docs/uri.html.in | 3 +-
include/libvirt/virterror.h | 2 +-
libvirt.spec.in | 14 +-
po/POTFILES.in | 1 -
proxy/.gitignore | 5 -
proxy/Makefile.am | 42 --
proxy/libvirt_proxy.c | 856 -----------------------------
src/Makefile.am | 1 -
src/conf/cpu_conf.c | 2 -
src/conf/cpu_conf.h | 6 +-
src/conf/domain_conf.c | 17 -
src/conf/domain_conf.h | 2 -
src/conf/nwfilter_params.c | 3 -
src/conf/storage_encryption_conf.c | 3 -
src/util/util.c | 67 ++--
src/xen/proxy_internal.c | 1044 ------------------------------------
src/xen/proxy_internal.h | 100 ----
src/xen/xen_driver.c | 56 +--
src/xen/xen_driver.h | 20 +-
src/xen/xen_hypervisor.c | 34 +-
src/xen/xen_hypervisor.h | 1 -
src/xen/xend_internal.c | 56 +--
src/xen/xs_internal.c | 78 +---
src/xen/xs_internal.h | 3 -
28 files changed, 74 insertions(+), 2374 deletions(-)
delete mode 100644 proxy/.gitignore
delete mode 100644 proxy/Makefile.am
delete mode 100644 proxy/libvirt_proxy.c
delete mode 100644 src/xen/proxy_internal.c
delete mode 100644 src/xen/proxy_internal.h
diff --git a/Makefile.am b/Makefile.am
index 26c6488..d05b7da 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,7 @@
LCOV = lcov
GENHTML = genhtml
-SUBDIRS = gnulib/lib include src daemon tools proxy docs gnulib/tests \
+SUBDIRS = gnulib/lib include src daemon tools docs gnulib/tests \
python tests po examples/domain-events/events-c examples/hellolibvirt \
examples/dominfo examples/domsuspend examples/python examples/apparmor \
examples/xml/nwfilter examples/openauth examples/systemtap
diff --git a/autobuild.sh b/autobuild.sh
index 4eda788..130f72d 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -17,8 +17,7 @@ rm -rf coverage
./autogen.sh --prefix="$AUTOBUILD_INSTALL_ROOT" \
--enable-test-coverage \
- --enable-compile-warnings=error \
- --with-xen-proxy
+ --enable-compile-warnings=error
# If the MAKEFLAGS envvar does not yet include a -j option,
# add -jN where N depends on the number of processors.
diff --git a/cfg.mk b/cfg.mk
index d238a5f..16c2ae3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -346,7 +346,6 @@ msg_gen_function += virLibConnError
msg_gen_function += virLibDomainError
msg_gen_function += virNetworkReportError
msg_gen_function += virNodeDeviceReportError
-msg_gen_function += virProxyError
msg_gen_function += virRaiseError
msg_gen_function += virReportErrorHelper
msg_gen_function += virReportSystemError
diff --git a/configure.ac b/configure.ac
index 6b30d90..445bcfe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1893,29 +1893,6 @@ if test "$enable_locking" = "yes"; then
fi
AM_CONDITIONAL([WITH_CIL],[test "$enable_locking" = "yes"])
-dnl Enable building the proxy?
-
-AC_ARG_WITH([xen-proxy],
- AC_HELP_STRING([--with-xen-proxy], [add XEN setuid proxy support @<:@default=auto@:>@]),[],[with_xen_proxy=auto])
-
-AC_MSG_CHECKING([if Xen setuid proxy is needed])
-if test "$with_xen_proxy" = "auto"; then
- if test "$with_polkit" = "yes"; then
- with_xen_proxy="no"
- else
- with_xen_proxy="yes"
- fi
-fi
-if test "$with_xen" != "yes"; then
- with_xen_proxy="no"
-fi
-AC_MSG_RESULT([$with_xen_proxy])
-
-AM_CONDITIONAL([WITH_PROXY],[test "$with_xen_proxy" = "yes"])
-if test "$with_xen_proxy" = "yes"; then
- AC_DEFINE([WITH_PROXY], 1, [Whether Xen proxy is enabled])
-fi
-
dnl Enable building libvirtd?
AM_CONDITIONAL([WITH_LIBVIRTD],[test "x$with_libvirtd" = "xyes"])
@@ -2258,7 +2235,7 @@ AC_OUTPUT(Makefile src/Makefile include/Makefile docs/Makefile \
python/Makefile python/tests/Makefile \
daemon/Makefile \
tools/Makefile \
- tests/Makefile proxy/Makefile \
+ tests/Makefile \
tests/xml2sexprdata/Makefile \
tests/sexpr2xmldata/Makefile \
tests/xmconfigdata/Makefile \
@@ -2281,7 +2258,6 @@ AC_MSG_NOTICE([])
AC_MSG_NOTICE([Drivers])
AC_MSG_NOTICE([])
AC_MSG_NOTICE([ Xen: $with_xen])
-AC_MSG_NOTICE([ Proxy: $with_xen_proxy])
AC_MSG_NOTICE([ QEMU: $with_qemu])
AC_MSG_NOTICE([ UML: $with_uml])
AC_MSG_NOTICE([ OpenVZ: $with_openvz])
diff --git a/docs/uri.html.in b/docs/uri.html.in
index 39c308b..e6326b2 100644
--- a/docs/uri.html.in
+++ b/docs/uri.html.in
@@ -302,7 +302,8 @@ connection.
</p>
<p>
You should consider using <a href="remote.html">libvirt remote support</a>
-in future.
+in future. <span class="since">Since 0.8.6</span> libvirt doesn't contain
+the Xen proxy anymore and you should use libvirtd instead.
</p>
</body>
</html>
diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h
index 78114e9..a4626ed 100644
--- a/include/libvirt/virterror.h
+++ b/include/libvirt/virterror.h
@@ -45,7 +45,7 @@ typedef enum {
VIR_FROM_XML, /* Error in the XML code */
VIR_FROM_DOM, /* Error when operating on a domain */
VIR_FROM_RPC, /* Error in the XML-RPC code */
- VIR_FROM_PROXY, /* Error in the proxy code */
+ VIR_FROM_PROXY, /* Error in the proxy code */ /* unused since 0.8.6 */
VIR_FROM_CONF, /* Error in the configuration file handling */
VIR_FROM_QEMU, /* Error at the QEMU daemon */
VIR_FROM_NET, /* Error when operating on a network */
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 869b5cc..813e0c0 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -31,7 +31,6 @@
# Then the hypervisor drivers that run on local host
%define with_xen 0%{!?_without_xen:%{server_drivers}}
-%define with_xen_proxy 0%{!?_without_xen_proxy:%{server_drivers}}
%define with_qemu 0%{!?_without_qemu:%{server_drivers}}
%define with_openvz 0%{!?_without_openvz:%{server_drivers}}
%define with_lxc 0%{!?_without_lxc:%{server_drivers}}
@@ -115,11 +114,6 @@
%define with_xen 0
%endif
-# If Xen isn't turned on, we shouldn't build the xen proxy either
-%if ! %{with_xen}
-%define with_xen_proxy 0
-%endif
-
# Fedora doesn't have any QEMU on ppc64 - only ppc
%if 0%{?fedora}
%ifarch ppc64
@@ -127,11 +121,9 @@
%endif
%endif
-# PolicyKit was introduced in Fedora 8 / RHEL-6 or newer, allowing
-# the setuid Xen proxy to be killed off
+# PolicyKit was introduced in Fedora 8 / RHEL-6 or newer
%if 0%{?fedora} >= 8 || 0%{?rhel} >= 6
%define with_polkit 0%{!?_without_polkit:1}
-%define with_xen_proxy 0
%endif
# libcapng is used to manage capabilities in Fedora 12 / RHEL-6 or newer
@@ -848,10 +840,6 @@ fi
%dir %attr(0700, root, root) %{_localstatedir}/log/libvirt/
-%if %{with_xen_proxy}
-%attr(4755, root, root) %{_libexecdir}/libvirt_proxy
-%endif
-
%if %{with_lxc}
%attr(0755, root, root) %{_libexecdir}/libvirt_lxc
%endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ec974cc..d8a4416 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -97,7 +97,6 @@ src/util/xml.c
src/vbox/vbox_XPCOMCGlue.c
src/vbox/vbox_driver.c
src/vbox/vbox_tmpl.c
-src/xen/proxy_internal.c
src/xen/xen_driver.c
src/xen/xen_hypervisor.c
src/xen/xen_inotify.c
diff --git a/proxy/.gitignore b/proxy/.gitignore
deleted file mode 100644
index f3d6ec7..0000000
--- a/proxy/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-Makefile
-Makefile.in
-.deps
-.libs
-libvirt_proxy
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
deleted file mode 100644
index c9859a0..0000000
--- a/proxy/Makefile.am
+++ /dev/null
@@ -1,42 +0,0 @@
-## Process this file with automake to produce Makefile.in
-
-if WITH_PROXY
-INCLUDES = -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
- -I$(top_builddir)/include -I@top_srcdir@/include \
- -I@top_srcdir@/proxy -I@top_srcdir@/src \
- -I@top_srcdir@/src/util \
- -I@top_srcdir@/src/conf \
- -I@top_srcdir@/src/xen \
- $(LIBXML_CFLAGS) \
- -DPROXY -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
- -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) $(XEN_CFLAGS)
-
-libexec_PROGRAMS = libvirt_proxy
-
-libvirt_proxy_SOURCES = libvirt_proxy.c \
- @top_srcdir(a)/src/util/buf.c \
- @top_srcdir(a)/src/util/files.c \
- @top_srcdir(a)/src/util/hash.c \
- @top_srcdir(a)/src/util/logging.c \
- @top_srcdir(a)/src/util/memory.c \
- @top_srcdir(a)/src/util/network.c \
- @top_srcdir(a)/src/util/threads.c \
- @top_srcdir(a)/src/util/util.c \
- @top_srcdir(a)/src/util/uuid.c \
- @top_srcdir(a)/src/util/virterror.c \
- @top_srcdir(a)/src/conf/capabilities.c \
- @top_srcdir(a)/src/conf/storage_encryption_conf.c \
- @top_srcdir(a)/src/conf/domain_conf.c \
- @top_srcdir(a)/src/conf/cpu_conf.c \
- @top_srcdir(a)/src/conf/nwfilter_params.c \
- @top_srcdir(a)/src/xen/xend_internal.c \
- @top_srcdir(a)/src/xen/xen_hypervisor.c \
- @top_srcdir(a)/src/xen/sexpr.c \
- @top_srcdir(a)/src/xen/xs_internal.c
-libvirt_proxy_LDFLAGS = $(WARN_LDFLAGS)
-libvirt_proxy_DEPENDENCIES =
-libvirt_proxy_LDADD = ../gnulib/lib/libgnu.la $(XEN_LIBS) $(LIB_PTHREAD)
-
-install-exec-hook:
- chmod u+s $(DESTDIR)$(libexecdir)/libvirt_proxy
-endif
diff --git a/proxy/libvirt_proxy.c b/proxy/libvirt_proxy.c
deleted file mode 100644
index 695a652..0000000
--- a/proxy/libvirt_proxy.c
+++ /dev/null
@@ -1,856 +0,0 @@
-/*
- * proxy_svr.c: root suid proxy server for Xen access to APIs with no
- * side effects from unauthenticated clients.
- *
- * Copyright (C) 2006, 2007, 2008, 2009 Red Hat, Inc.
- *
- * See COPYING.LIB for the License of this software
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-#include <config.h>
-#include <stdio.h>
-
-#ifdef WITH_XEN
-
-# include <stdlib.h>
-# include <unistd.h>
-# include <errno.h>
-# include <sys/types.h>
-# include <sys/poll.h>
-# include <sys/socket.h>
-# include <sys/un.h>
-# include <locale.h>
-
-# include "internal.h"
-# include "datatypes.h"
-# include "proxy_internal.h"
-# include "util.h"
-# include "xen_hypervisor.h"
-# include "xend_internal.h"
-# include "xs_internal.h"
-# include "xen_driver.h"
-
-static int fdServer = -1;
-static int debug = 0;
-static int persist = 0;
-static int done = 0;
-
-# define MAX_CLIENT 64
-
-static int nbClients = 0; /* client 0 is the unix listen socket */
-static struct pollfd pollInfos[MAX_CLIENT + 1];
-
-static virConnect conninfos;
-static virConnectPtr conn = &conninfos;
-
-static unsigned long xenVersion = 0;
-
-/************************************************************************
- * *
- * Interfaces with the Xen hypervisor *
- * *
- ************************************************************************/
-
-/**
- * proxyInitXen:
- *
- * Initialize the communication layer with Xen
- *
- * Returns 0 or -1 in case of error
- */
-static int
-proxyInitXen(void) {
- int ret;
- unsigned long xenVersion2;
- xenUnifiedPrivatePtr priv;
-
- /* Allocate per-connection private data. */
- priv = malloc (sizeof *priv);
- if (!priv) {
- fprintf(stderr, "Failed to allocate private data\n");
- return(-1);
- }
- conn->privateData = priv;
-
- priv->handle = -1;
- priv->xendConfigVersion = -1;
- priv->xshandle = NULL;
- priv->proxy = -1;
-
- ret = xenHypervisorOpen(conn, NULL, 0);
- if (ret < 0) {
- fprintf(stderr, "Failed to open Xen hypervisor\n");
- return(-1);
- } else {
- ret = xenHypervisorGetVersion(conn, &xenVersion);
- if (ret != 0) {
- fprintf(stderr, "Failed to get Xen hypervisor version\n");
- return(-1);
- }
- }
- ret = xenDaemonOpen_unix(conn, "/var/lib/xend/xend-socket");
- if (ret < 0) {
- fprintf(stderr, "Failed to connect to Xen daemon\n");
- return(-1);
- }
- ret = xenStoreOpen(conn, NULL, VIR_CONNECT_RO);
- if (ret < 0) {
- fprintf(stderr, "Failed to open XenStore connection");
- return (-1);
- }
- ret = xenDaemonGetVersion(conn, &xenVersion2);
- if (ret != 0) {
- fprintf(stderr, "Failed to get Xen daemon version\n");
- return(-1);
- }
- if (debug)
- fprintf(stderr, "Connected to hypervisor %lu and daemon %lu\n",
- xenVersion, xenVersion2);
- if (xenVersion2 > xenVersion)
- xenVersion = xenVersion2;
- return(0);
-}
-
-/************************************************************************
- * *
- * Processing of the unix socket to listen for clients *
- * *
- ************************************************************************/
-
-/**
- * proxyCloseUnixSocket:
- *
- * close the unix socket
- *
- * Returns 0 or -1 in case of error
- */
-static int
-proxyCloseUnixSocket(void) {
- int ret;
-
- if (fdServer < 0)
- return(0);
-
- ret = close(fdServer);
- if (debug > 0)
- fprintf(stderr, "closing unix socket %d: %d\n", fdServer, ret);
- fdServer = -1;
- pollInfos[0].fd = -1;
- return(ret);
-}
-
-/**
- * proxyListenUnixSocket:
- * @path: the filename for the socket
- *
- * create a new abstract socket based on that path and listen on it
- *
- * Returns the associated file descriptor or -1 in case of failure
- */
-static int
-proxyListenUnixSocket(const char *path) {
- int fd;
- struct sockaddr_un addr;
-
- if (fdServer >= 0)
- return(fdServer);
-
- fd = socket(PF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- fprintf(stderr, "Failed to create unix socket");
- return(-1);
- }
-
- /*
- * Abstract socket do not hit the filesystem, way more secure and
- * guaranteed to be atomic
- */
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
- addr.sun_path[0] = '\0';
- if (virStrcpy(&addr.sun_path[1], path, sizeof(addr.sun_path) - 1) == NULL) {
- fprintf(stderr, "Path %s too long to fit into destination\n", path);
- close(fd);
- return -1;
- }
-
- /*
- * now bind the socket to that address and listen on it
- */
- if (bind(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- fprintf(stderr, "Failed to bind to socket %s\n", path);
- close(fd);
- return (-1);
- }
- if (listen(fd, 30 /* backlog */ ) < 0) {
- fprintf(stderr, "Failed to listen to socket %s\n", path);
- close(fd);
- return (-1);
- }
-
- if (debug > 0)
- fprintf(stderr, "opened and bound unix socket %d\n", fd);
-
- fdServer = fd;
- pollInfos[0].fd = fd;
- pollInfos[0].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
- return (fd);
-}
-
-/**
- * proxyAcceptClientSocket:
- *
- * Process a request to the unix socket
- *
- * Returns the filedescriptor of the new client or -1 in case of error
- */
-static int
-proxyAcceptClientSocket(void) {
- int client;
- socklen_t client_addrlen;
- struct sockaddr client_addr;
-
-retry:
- client_addrlen = sizeof(client_addr);
- client = accept(pollInfos[0].fd, &client_addr, &client_addrlen);
- if (client < 0) {
- if (errno == EINTR) {
- if (debug > 0)
- fprintf(stderr, "accept connection on socket %d interrupted\n",
- pollInfos[0].fd);
- goto retry;
- }
- fprintf(stderr, "Failed to accept incoming connection on socket %d\n",
- pollInfos[0].fd);
- done = 1;
- return(-1);
- }
-
- if (nbClients >= MAX_CLIENT) {
- fprintf(stderr, "Too many client registered\n");
- close(client);
- return(-1);
- }
- nbClients++;
- pollInfos[nbClients].fd = client;
- pollInfos[nbClients].events = POLLIN | POLLERR | POLLHUP | POLLNVAL;
- if (debug > 0)
- fprintf(stderr, "accept connection on socket %d for client %d\n",
- client, nbClients);
- return(client);
-}
-
-/************************************************************************
- * *
- * Processing of client sockets *
- * *
- ************************************************************************/
-
-/**
- * proxyCloseClientSocket:
- * @nr: client number
- *
- * Close the socket from that client, and recompact the pollInfo array
- *
- * Returns 0 in case of success and -1 in case of error
- */
-static int
-proxyCloseClientSocket(int nr) {
- int ret;
-
- ret = close(pollInfos[nr].fd);
- if (ret != 0)
- fprintf(stderr, "Failed to close socket %d from client %d\n",
- pollInfos[nr].fd, nr);
- else if (debug > 0)
- fprintf(stderr, "Closed socket %d from client %d\n",
- pollInfos[nr].fd, nr);
- if (nr < nbClients) {
- memmove(&pollInfos[nr], &pollInfos[nr + 1],
- (nbClients - nr) * sizeof(pollInfos[0]));
- }
- nbClients--;
- return(ret);
-}
-
-/**
- * proxyCloseClientSockets:
- *
- * Close all the sockets from the clients
- */
-static void
-proxyCloseClientSockets(void) {
- int i, ret;
-
- for (i = 1;i <= nbClients;i++) {
- ret = close(pollInfos[i].fd);
- if (ret != 0)
- fprintf(stderr, "Failed to close socket %d from client %d\n",
- pollInfos[i].fd, i);
- else if (debug > 0)
- fprintf(stderr, "Closed socket %d from client %d\n",
- pollInfos[i].fd, i);
- }
- nbClients = 0;
-}
-
-/**
- * proxyWriteClientSocket:
- * @nr: the client number
- * @req: pointer to the packet
- *
- * Send back a packet to the client. If it seems write would be blocking
- * then try to disconnect from it.
- *
- * Return 0 in case of success and -1 in case of error.
- */
-static int
-proxyWriteClientSocket(int nr, virProxyPacketPtr req) {
- int ret;
-
- if ((nr <= 0) || (nr > nbClients) || (req == NULL) ||
- (req->len < sizeof(virProxyPacket)) ||
- (req->len > sizeof(virProxyFullPacket)) ||
- (pollInfos[nr].fd < 0)) {
- fprintf(stderr, "write to client %d in error", nr);
- proxyCloseClientSocket(nr);
- return(-1);
- }
-
- ret = safewrite(pollInfos[nr].fd, (char *) req, req->len);
- if (ret < 0) {
- fprintf(stderr, "write %d bytes to socket %d from client %d failed\n",
- req->len, pollInfos[nr].fd, nr);
- proxyCloseClientSocket(nr);
- return(-1);
- }
- if (ret == 0) {
- if (debug)
- fprintf(stderr, "end of stream from client %d on socket %d\n",
- nr, pollInfos[nr].fd);
- proxyCloseClientSocket(nr);
- return(-1);
- }
-
- if (ret != req->len) {
- fprintf(stderr, "write %d of %d bytes to socket %d from client %d\n",
- ret, req->len, pollInfos[nr].fd, nr);
- proxyCloseClientSocket(nr);
- return(-1);
- }
- if (debug)
- fprintf(stderr, "wrote %d bytes to client %d on socket %d\n",
- ret, nr, pollInfos[nr].fd);
-
- return(0);
-}
-/**
- * proxyReadClientSocket:
- * @nr: the client number
- *
- * Process a read from a client socket
- */
-static int
-proxyReadClientSocket(int nr) {
- virDomainDefPtr def;
- union {
- virProxyFullPacket full_request;
- virProxyPacket request;
- } r;
- virProxyPacketPtr req = &r.request;
- int ret;
- char *xml, *ostype;
-
-retry:
- ret = read(pollInfos[nr].fd, req, sizeof(virProxyPacket));
- if (ret < 0) {
- if (errno == EINTR) {
- if (debug > 0)
- fprintf(stderr, "read socket %d from client %d interrupted\n",
- pollInfos[nr].fd, nr);
- goto retry;
- }
- fprintf(stderr, "Failed to read socket %d from client %d\n",
- pollInfos[nr].fd, nr);
- proxyCloseClientSocket(nr);
- return(-1);
- }
- if (ret == 0) {
- if (debug)
- fprintf(stderr, "end of stream from client %d on socket %d\n",
- nr, pollInfos[nr].fd);
- proxyCloseClientSocket(nr);
- return(-1);
- }
-
- if (debug)
- fprintf(stderr, "read %d bytes from client %d on socket %d\n",
- ret, nr, pollInfos[nr].fd);
-
- if ((ret != sizeof(virProxyPacket)) ||
- (req->version != PROXY_PROTO_VERSION) ||
- (req->len < sizeof(virProxyPacket)) ||
- (req->len > sizeof(virProxyFullPacket)))
- goto comm_error;
-
-
- if (debug)
- fprintf(stderr, "Got command %d from client %d\n", req->command, nr);
-
- /*
- * complete reading the packet.
- * TODO: we should detect when blocking and abort connection if this happen
- */
- if (req->len > ret) {
- int total, extra;
- char *base = (char *) &r;
-
- total = ret;
- while (total < req->len) {
- extra = req->len - total;
-retry2:
- ret = read(pollInfos[nr].fd, base + total, extra);
- if (ret < 0) {
- if (errno == EINTR) {
- if (debug > 0)
- fprintf(stderr,
- "read socket %d from client %d interrupted\n",
- pollInfos[nr].fd, nr);
- goto retry2;
- }
- fprintf(stderr, "Failed to read socket %d from client %d\n",
- pollInfos[nr].fd, nr);
- proxyCloseClientSocket(nr);
- return(-1);
- }
- if (ret == 0) {
- if (debug)
- fprintf(stderr,
- "end of stream from client %d on socket %d\n",
- nr, pollInfos[nr].fd);
- proxyCloseClientSocket(nr);
- return(-1);
- }
- total += ret;
- }
- }
- switch (req->command) {
- case VIR_PROXY_NONE:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
- break;
- case VIR_PROXY_VERSION:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
- req->data.larg = xenVersion;
- break;
- case VIR_PROXY_LIST: {
- int maxids;
-
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
- maxids = sizeof(r.full_request.extra.arg) / sizeof(int);
- ret = xenHypervisorListDomains(conn, &r.full_request.extra.arg[0],
- maxids);
- if (ret < 0) {
- req->len = sizeof(virProxyPacket);
- req->data.arg = 0;
- } else {
- req->len = sizeof(virProxyPacket) + ret * sizeof(int);
- req->data.arg = ret;
- }
- break;
- }
- case VIR_PROXY_NUM_DOMAIN:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
- req->data.arg = xenHypervisorNumOfDomains(conn);
- break;
- case VIR_PROXY_MAX_MEMORY:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
- req->data.larg = xenHypervisorGetDomMaxMemory(conn, req->data.arg);
- break;
- case VIR_PROXY_DOMAIN_INFO:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
- memset(&r.full_request.extra.dinfo, 0, sizeof(virDomainInfo));
- ret = xenHypervisorGetDomInfo(conn, req->data.arg,
- &r.full_request.extra.dinfo);
- if (ret < 0) {
- req->data.arg = -1;
- } else {
- req->len += sizeof(virDomainInfo);
- }
- break;
- case VIR_PROXY_LOOKUP_ID: {
- char *name = NULL;
- unsigned char uuid[VIR_UUID_BUFLEN];
- int len;
-
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
-
- if (xenDaemonDomainLookupByID(conn, req->data.arg, &name, uuid) < 0) {
- req->data.arg = -1;
- } else {
- len = strlen(name);
- if (len > 1000) {
- len = 1000;
- name[1000] = 0;
- }
- req->len += VIR_UUID_BUFLEN + len + 1;
- memcpy(&r.full_request.extra.str[0], uuid, VIR_UUID_BUFLEN);
- strcpy(&r.full_request.extra.str[VIR_UUID_BUFLEN], name);
- }
- free(name);
- break;
- }
- case VIR_PROXY_LOOKUP_UUID: {
- char **names;
- char **tmp;
- int ident, len;
- char *name = NULL;
- unsigned char uuid[VIR_UUID_BUFLEN];
-
- if (req->len != sizeof(virProxyPacket) + VIR_UUID_BUFLEN)
- goto comm_error;
-
- /*
- * Xend API forces to collect the full domain list by names, and
- * then query each of them until the id is found
- */
- names = xenDaemonListDomainsOld(conn);
- tmp = names;
-
- if (names != NULL) {
- while (*tmp != NULL) {
- ident = xenDaemonDomainLookupByName_ids(conn, *tmp, &uuid[0]);
- if (!memcmp(uuid, &r.full_request.extra.str[0], VIR_UUID_BUFLEN)) {
- name = *tmp;
- break;
- }
- tmp++;
- }
- }
- if (name == NULL) {
- /* not found */
- req->data.arg = -1;
- req->len = sizeof(virProxyPacket);
- } else {
- len = strlen(name);
- if (len > 1000) {
- len = 1000;
- name[1000] = 0;
- }
- req->len = sizeof(virProxyPacket) + len + 1;
- strcpy(&r.full_request.extra.str[0], name);
- req->data.arg = ident;
- }
- free(names);
- break;
- }
- case VIR_PROXY_LOOKUP_NAME: {
- int ident;
- unsigned char uuid[VIR_UUID_BUFLEN];
-
- if (req->len > sizeof(virProxyPacket) + 1000)
- goto comm_error;
-
- ident = xenDaemonDomainLookupByName_ids(conn,
- &r.full_request.extra.str[0], &uuid[0]);
- if (ident < 0) {
- /* not found */
- req->data.arg = -1;
- req->len = sizeof(virProxyPacket);
- } else {
- req->len = sizeof(virProxyPacket) + VIR_UUID_BUFLEN;
- memcpy(&r.full_request.extra.str[0], uuid, VIR_UUID_BUFLEN);
- req->data.arg = ident;
- }
- break;
- }
- case VIR_PROXY_NODE_INFO:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
-
- /*
- * Hum, could we expect those information to be unmutable and
- * cache them ? Since it's probably an unfrequent call better
- * not make assumption and do the xend RPC each call.
- */
- ret = xenDaemonNodeGetInfo(conn, &r.full_request.extra.ninfo);
- if (ret < 0) {
- req->data.arg = -1;
- req->len = sizeof(virProxyPacket);
- } else {
- req->data.arg = 0;
- req->len = sizeof(virProxyPacket) + sizeof(virNodeInfo);
- }
- break;
-
- case VIR_PROXY_GET_CAPABILITIES:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
-
- xml = xenHypervisorGetCapabilities (conn);
- if (!xml) {
- req->data.arg = -1;
- req->len = sizeof (virProxyPacket);
- } else {
- int xmllen = strlen (xml);
- if (xmllen > (int) sizeof (r.full_request.extra.str)) {
- req->data.arg = -2;
- req->len = sizeof (virProxyPacket);
- } else {
- req->data.arg = 0;
- memmove (r.full_request.extra.str, xml, xmllen);
- req->len = sizeof (virProxyPacket) + xmllen;
- }
- free (xml);
- }
- break;
-
- case VIR_PROXY_DOMAIN_XML:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
-
- /*
- * Ideally we should get the CPUs used by the domain
- * but that information is really node specific and it
- * rather hard to get from that code path. So proxy
- * users won't see CPU pinning (last NULL arg)
- */
- def = xenDaemonDomainFetch(conn, r.full_request.data.arg, NULL, NULL);
- if (!def) {
- req->data.arg = -1;
- req->len = sizeof(virProxyPacket);
- } else {
- xml = virDomainDefFormat(def, 0);
- if (!xml) {
- req->data.arg = -1;
- req->len = sizeof(virProxyPacket);
- } else {
- int xmllen = strlen(xml);
- if (xmllen > (int) sizeof(r.full_request.extra.str)) {
- req->data.arg = -2;
- req->len = sizeof(virProxyPacket);
- } else {
- req->data.arg = 0;
- memmove(&r.full_request.extra.str[0], xml, xmllen);
- req->len = sizeof(virProxyPacket) + xmllen;
- }
- free(xml);
- }
- }
- virDomainDefFree(def);
- break;
- case VIR_PROXY_DOMAIN_OSTYPE:
- if (req->len != sizeof(virProxyPacket))
- goto comm_error;
-
- ostype = xenStoreDomainGetOSTypeID(conn, r.full_request.data.arg);
- if (!ostype) {
- req->data.arg = -1;
- req->len = sizeof(virProxyPacket);
- } else {
- int ostypelen = strlen(ostype);
- if (ostypelen > (int) sizeof(r.full_request.extra.str)) {
- req->data.arg = -2;
- req->len = sizeof(virProxyPacket);
- } else {
- req->data.arg = 0;
- memmove(&r.full_request.extra.str[0], ostype, ostypelen);
- req->len = sizeof(virProxyPacket) + ostypelen;
- }
- free(ostype);
- }
- break;
- default:
- goto comm_error;
- }
- ret = proxyWriteClientSocket(nr, req);
- return(ret);
-
-comm_error:
- fprintf(stderr,
- "Communication error with client %d: malformed packet\n", nr);
- proxyCloseClientSocket(nr);
- return(-1);
-}
-
-/************************************************************************
- * *
- * Main loop processing *
- * *
- ************************************************************************/
-
-/**
- * proxyProcessRequests:
- *
- * process requests and timers
- */
-static void
-proxyProcessRequests(void) {
- int exit_timeout = 30;
- int ret, i;
-
- while (!done) {
- /*
- * wait for requests, with a one second timeout
- */
- ret = poll(&pollInfos[0], nbClients + 1, 1000);
- if (ret == 0) { /* timeout */
- if ((nbClients == 0) && (persist == 0)) {
- exit_timeout--;
- if (exit_timeout == 0) {
- done = 1;
- if (debug > 0) {
- fprintf(stderr, "Exiting after 30s without clients\n");
- }
- }
- } else
- exit_timeout = 30;
- if (debug > 1)
- fprintf(stderr, "poll timeout\n");
- continue;
- } else if (ret < 0) {
- if (errno == EINTR) {
- if (debug > 0)
- fprintf(stderr, "poll syscall interrupted\n");
- continue;
- }
- fprintf(stderr, "poll syscall failed\n");
- break;
- }
- /*
- * there have been I/O to process
- */
- exit_timeout = 30;
- if (pollInfos[0].revents != 0) {
- if (pollInfos[0].revents & POLLIN) {
- proxyAcceptClientSocket();
- } else {
- fprintf(stderr, "Got an error %d on incoming socket %d\n",
- pollInfos[0].revents, pollInfos[0].fd);
- break;
- }
- }
-
- /*
- * process the clients in reverse order since on error or disconnect
- * pollInfos is compacted to remove the given client.
- */
- for (i = nbClients;i > 0;i--) {
- if (pollInfos[i].revents & POLLIN) {
- proxyReadClientSocket(i);
- } else if (pollInfos[i].revents != 0) {
- fprintf(stderr, "Got an error %d on client %d socket %d\n",
- pollInfos[i].revents, i, pollInfos[i].fd);
- proxyCloseClientSocket(i);
- }
- }
-
- }
-}
-
-/**
- * proxyMainLoop:
- *
- * main loop for the proxy, continually try to keep the unix socket
- * open, serve client requests, and process timing events.
- */
-
-static void
-proxyMainLoop(void) {
- while (! done) {
- if (proxyListenUnixSocket(PROXY_SOCKET_PATH) < 0)
- break;
- proxyProcessRequests();
- }
- proxyCloseClientSockets();
-}
-
-/**
- * usage:
- *
- * dump on stdout information about the program
- */
-static void
-usage(const char *progname) {
- printf("Usage: %s [-v] [-v]\n", progname);
- printf(" option -v increase the verbosity level for debugging\n");
- printf("This is a proxy for xen services used by libvirt to offer\n");
- printf("safe and fast status information on the Xen virtualization.\n");
- printf("This need not be run manually it's started automatically.\n");
-}
-
-/**
- * main:
- *
- * Check that we are running with root privileges, initialize the
- * connections to the daemon and or hypervisor, and then run the main loop
- */
-int main(int argc, char **argv) {
- int i;
-
- if (!setlocale(LC_ALL, "")) {
- perror("setlocale");
- return -1;
- }
- if (!bindtextdomain(GETTEXT_PACKAGE, LOCALEBASEDIR)) {
- perror("bindtextdomain");
- return -1;
- }
- if (!textdomain(GETTEXT_PACKAGE)) {
- perror("textdomain");
- return -1;
- }
-
- for (i = 1; i < argc; i++) {
- if (STREQ(argv[i], "-v")) {
- debug++;
- } else if (STREQ(argv[i], "-no-timeout")) {
- persist = 1;
- } else {
- usage(argv[0]);
- exit(EXIT_FAILURE);
- }
- }
-
-
- if (geteuid() != 0) {
- fprintf(stderr, "%s must be run as root or suid\n", argv[0]);
- /* exit(EXIT_FAILURE); */
- }
-
- /*
- * setup a connection block
- */
- memset(conn, 0, sizeof(conninfos));
- conn->magic = VIR_CONNECT_MAGIC;
-
- /*
- * very fist thing, use the socket as an exclusive lock, this then
- * allow to do timed exits, avoiding constant CPU usage in case of
- * failure.
- */
- if (proxyListenUnixSocket(PROXY_SOCKET_PATH) < 0)
- exit(EXIT_SUCCESS);
- if (proxyInitXen() == 0)
- proxyMainLoop();
- sleep(1);
- proxyCloseUnixSocket();
- exit(EXIT_SUCCESS);
-}
-
-#else /* WITHOUT_XEN */
-
-int main(void) {
- fprintf(stderr, "libvirt was compiled without Xen support\n");
- exit(EXIT_FAILURE);
-}
-
-#endif /* WITH_XEN */
diff --git a/src/Makefile.am b/src/Makefile.am
index b9376be..7f43a48 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -228,7 +228,6 @@ TEST_DRIVER_SOURCES = \
# Now the Hypervisor specific drivers
XEN_DRIVER_SOURCES = \
- xen/proxy_internal.c xen/proxy_internal.h \
xen/sexpr.c xen/sexpr.h \
xen/block_stats.c xen/block_stats.h \
xen/xen_hypervisor.c xen/xen_hypervisor.h \
diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c
index 68d3daf..f8d006d 100644
--- a/src/conf/cpu_conf.c
+++ b/src/conf/cpu_conf.c
@@ -106,7 +106,6 @@ no_memory:
}
-#ifndef PROXY
virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node,
xmlXPathContextPtr ctxt,
@@ -298,7 +297,6 @@ error:
def = NULL;
goto cleanup;
}
-#endif
char *
diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h
index 1c29192..6151683 100644
--- a/src/conf/cpu_conf.h
+++ b/src/conf/cpu_conf.h
@@ -26,9 +26,7 @@
# include "util.h"
# include "buf.h"
-# ifndef PROXY
-# include "xml.h"
-# endif
+# include "xml.h"
enum virCPUType {
VIR_CPU_TYPE_HOST,
@@ -87,12 +85,10 @@ virCPUDefFree(virCPUDefPtr def);
virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu);
-# ifndef PROXY
virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node,
xmlXPathContextPtr ctxt,
enum virCPUType mode);
-# endif
enum virCPUFormatFlags {
VIR_CPU_FORMAT_EMBEDED = (1 << 0) /* embed into existing <cpu/> element
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 9f3c08e..7eb8fb3 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -335,8 +335,6 @@ VIR_ENUM_IMPL(virDomainTimerMode, VIR_DOMAIN_TIMER_MODE_LAST,
virReportErrorHelper(NULL, VIR_FROM_DOMAIN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
-#ifndef PROXY
-
int virDomainObjListInit(virDomainObjListPtr doms)
{
doms->objs = virHashCreate(50);
@@ -428,8 +426,6 @@ virDomainObjPtr virDomainFindByName(const virDomainObjListPtr doms,
return obj;
}
-#endif /* !PROXY */
-
void virDomainGraphicsDefFree(virDomainGraphicsDefPtr def)
{
if (!def)
@@ -813,8 +809,6 @@ void virDomainDefFree(virDomainDefPtr def)
VIR_FREE(def);
}
-#ifndef PROXY
-
static void virDomainSnapshotObjListDeinit(virDomainSnapshotObjListPtr snapshots);
static void virDomainObjFree(virDomainObjPtr dom)
{
@@ -990,7 +984,6 @@ int virDomainDeviceVirtioSerialAddressIsValid(
{
return 1; /* 0 is valid for all fields, so any successfully parsed addr is valid */
}
-#endif /* !PROXY */
int virDomainDeviceInfoIsSet(virDomainDeviceInfoPtr info)
@@ -1153,9 +1146,6 @@ static int virDomainDeviceInfoFormat(virBufferPtr buf,
}
-#ifndef PROXY
-
-
static int
virDomainDevicePCIAddressParseXML(xmlNodePtr node,
virDomainDevicePCIAddressPtr addr)
@@ -4045,7 +4035,6 @@ virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
VIR_FREE(dev);
return NULL;
}
-#endif /* !PROXY */
static const char *
@@ -4236,7 +4225,6 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
}
-#ifndef PROXY
static char *virDomainDefDefaultEmulator(virDomainDefPtr def,
virCapsPtr caps) {
const char *type;
@@ -5400,8 +5388,6 @@ int virDomainDefAddImplicitControllers(virDomainDefPtr def)
}
-#endif /* ! PROXY */
-
/************************************************************************
* *
* Parser and converter for the CPUset strings used in libvirt *
@@ -6949,7 +6935,6 @@ char *virDomainDefFormat(virDomainDefPtr def,
return NULL;
}
-#ifndef PROXY
static char *virDomainObjFormat(virCapsPtr caps,
virDomainObjPtr obj,
@@ -8020,5 +8005,3 @@ cleanup:
return ret;
}
-
-#endif /* ! PROXY */
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index 8e32c3b..5827ffb 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1057,7 +1057,6 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
void virDomainRemoveInactive(virDomainObjListPtr doms,
virDomainObjPtr dom);
-# ifndef PROXY
virDomainDeviceDefPtr virDomainDeviceDefParse(virCapsPtr caps,
const virDomainDefPtr def,
const char *xmlStr,
@@ -1081,7 +1080,6 @@ virDomainObjPtr virDomainObjParseNode(virCapsPtr caps,
int virDomainDefAddImplicitControllers(virDomainDefPtr def);
-# endif
char *virDomainDefFormat(virDomainDefPtr def,
int flags);
diff --git a/src/conf/nwfilter_params.c b/src/conf/nwfilter_params.c
index c57037f..7a59387 100644
--- a/src/conf/nwfilter_params.c
+++ b/src/conf/nwfilter_params.c
@@ -202,8 +202,6 @@ err_exit:
}
-#ifndef PROXY
-
static bool
isValidVarName(const char *var)
{
@@ -258,7 +256,6 @@ skip_entry:
}
return table;
}
-#endif
struct formatterParam {
diff --git a/src/conf/storage_encryption_conf.c b/src/conf/storage_encryption_conf.c
index 472a1e0..20e822c 100644
--- a/src/conf/storage_encryption_conf.c
+++ b/src/conf/storage_encryption_conf.c
@@ -68,8 +68,6 @@ virStorageEncryptionFree(virStorageEncryptionPtr enc)
VIR_FREE(enc);
}
-#ifndef PROXY
-
static virStorageEncryptionSecretPtr
virStorageEncryptionSecretParse(xmlXPathContextPtr ctxt,
xmlNodePtr node)
@@ -211,7 +209,6 @@ virStorageEncryptionParseNode(xmlDocPtr xml, xmlNodePtr root)
xmlXPathFreeContext(ctxt);
return enc;
}
-#endif /* ! PROXY */
static int
diff --git a/src/util/util.c b/src/util/util.c
index a059675..4827292 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -195,8 +195,6 @@ int safezero(int fd, int flags ATTRIBUTE_UNUSED, off_t offset, off_t len)
# endif /* HAVE_MMAP */
#endif /* HAVE_POSIX_FALLOCATE */
-#ifndef PROXY
-
int virFileStripSuffix(char *str,
const char *suffix)
{
@@ -241,14 +239,14 @@ virArgvToString(const char *const *argv)
}
int virSetNonBlock(int fd) {
-# ifndef WIN32
+#ifndef WIN32
int flags;
if ((flags = fcntl(fd, F_GETFL)) < 0)
return -1;
flags |= O_NONBLOCK;
if ((fcntl(fd, F_SETFL, flags)) < 0)
return -1;
-# else
+#else
unsigned long flag = 1;
/* This is actually Gnulib's replacement rpl_ioctl function.
@@ -256,12 +254,12 @@ int virSetNonBlock(int fd) {
*/
if (ioctl (fd, FIONBIO, (void *) &flag) == -1)
return -1;
-# endif
+#endif
return 0;
}
-# ifndef WIN32
+#ifndef WIN32
int virSetCloseExec(int fd) {
int flags;
@@ -274,7 +272,7 @@ int virSetCloseExec(int fd) {
}
-# if HAVE_CAPNG
+# if HAVE_CAPNG
static int virClearCapabilities(void)
{
int ret;
@@ -289,13 +287,13 @@ static int virClearCapabilities(void)
return 0;
}
-# else
+# else
static int virClearCapabilities(void)
{
// VIR_WARN0("libcap-ng support not compiled in, unable to clear capabilities");
return 0;
}
-# endif
+# endif
/* virFork() - fork a new process while avoiding various race/deadlock conditions
@@ -314,9 +312,9 @@ static int virClearCapabilities(void)
*/
int virFork(pid_t *pid) {
-# ifdef HAVE_PTHREAD_SIGMASK
+# ifdef HAVE_PTHREAD_SIGMASK
sigset_t oldmask, newmask;
-# endif
+# endif
struct sigaction sig_action;
int saved_errno, ret = -1;
@@ -326,7 +324,7 @@ int virFork(pid_t *pid) {
* Need to block signals now, so that child process can safely
* kill off caller's signal handlers without a race.
*/
-# ifdef HAVE_PTHREAD_SIGMASK
+# ifdef HAVE_PTHREAD_SIGMASK
sigfillset(&newmask);
if (pthread_sigmask(SIG_SETMASK, &newmask, &oldmask) != 0) {
saved_errno = errno;
@@ -334,7 +332,7 @@ int virFork(pid_t *pid) {
"%s", _("cannot block signals"));
goto cleanup;
}
-# endif
+# endif
/* Ensure we hold the logging lock, to protect child processes
* from deadlocking on another thread's inherited mutex state */
@@ -347,11 +345,11 @@ int virFork(pid_t *pid) {
virLogUnlock();
if (*pid < 0) {
-# ifdef HAVE_PTHREAD_SIGMASK
+# ifdef HAVE_PTHREAD_SIGMASK
/* attempt to restore signal mask, but ignore failure, to
avoid obscuring the fork failure */
ignore_value (pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
-# endif
+# endif
virReportSystemError(saved_errno,
"%s", _("cannot fork child process"));
goto cleanup;
@@ -361,7 +359,7 @@ int virFork(pid_t *pid) {
/* parent process */
-# ifdef HAVE_PTHREAD_SIGMASK
+# ifdef HAVE_PTHREAD_SIGMASK
/* Restore our original signal mask now that the child is
safely running */
if (pthread_sigmask(SIG_SETMASK, &oldmask, NULL) != 0) {
@@ -369,7 +367,7 @@ int virFork(pid_t *pid) {
virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup;
}
-# endif
+# endif
ret = 0;
} else {
@@ -405,7 +403,7 @@ int virFork(pid_t *pid) {
sigaction(i, &sig_action, NULL);
}
-# ifdef HAVE_PTHREAD_SIGMASK
+# ifdef HAVE_PTHREAD_SIGMASK
/* Unmask all signals in child, since we've no idea
what the caller's done with their signal mask
and don't want to propagate that to children */
@@ -415,7 +413,7 @@ int virFork(pid_t *pid) {
virReportSystemError(errno, "%s", _("cannot unblock signals"));
goto cleanup;
}
-# endif
+# endif
ret = 0;
}
@@ -873,7 +871,7 @@ virRunWithHook(const char *const*argv,
return ret;
}
-# else /* WIN32 */
+#else /* WIN32 */
int virSetCloseExec(int fd ATTRIBUTE_UNUSED)
{
@@ -937,7 +935,7 @@ virFork(pid_t *pid)
return -1;
}
-# endif /* WIN32 */
+#endif /* WIN32 */
int
virPipeReadUntilEOF(int outfd, int errfd,
@@ -1173,7 +1171,7 @@ int virFileHasSuffix(const char *str,
return STRCASEEQ(str + len - suffixlen, suffix);
}
-# define SAME_INODE(Stat_buf_1, Stat_buf_2) \
+#define SAME_INODE(Stat_buf_1, Stat_buf_2) \
((Stat_buf_1).st_ino == (Stat_buf_2).st_ino \
&& (Stat_buf_1).st_dev == (Stat_buf_2).st_dev)
@@ -1279,7 +1277,7 @@ int virFileExists(const char *path)
return(0);
}
-# ifndef WIN32
+#ifndef WIN32
/* return -errno on failure, or 0 on success */
static int virFileOperationNoFork(const char *path, int openflags, mode_t mode,
uid_t uid, gid_t gid,
@@ -1591,7 +1589,7 @@ childerror:
_exit(ret);
}
-# else /* WIN32 */
+#else /* WIN32 */
/* return -errno on failure, or 0 on success */
int virFileOperation(const char *path ATTRIBUTE_UNUSED,
@@ -1620,7 +1618,7 @@ int virDirCreate(const char *path ATTRIBUTE_UNUSED,
return -1;
}
-# endif /* WIN32 */
+#endif /* WIN32 */
static int virFileMakePathHelper(char *path) {
struct stat st;
@@ -1714,7 +1712,7 @@ int virFileOpenTty(int *ttymaster,
rawmode);
}
-# ifdef __linux__
+#ifdef __linux__
int virFileOpenTtyAt(const char *ptmx,
int *ttymaster,
char **ttyName,
@@ -1764,7 +1762,7 @@ cleanup:
return rc;
}
-# else
+#else
int virFileOpenTtyAt(const char *ptmx ATTRIBUTE_UNUSED,
int *ttymaster ATTRIBUTE_UNUSED,
char **ttyName ATTRIBUTE_UNUSED,
@@ -1772,7 +1770,7 @@ int virFileOpenTtyAt(const char *ptmx ATTRIBUTE_UNUSED,
{
return -1;
}
-# endif
+#endif
char* virFilePid(const char *dir, const char* name)
{
@@ -1911,7 +1909,6 @@ cleanup:
return rc;
}
-#endif /* PROXY */
/*
* Creates an absolute path for a potentialy realtive path.
@@ -2861,15 +2858,14 @@ virFileFindMountPoint(const char *type ATTRIBUTE_UNUSED)
#endif /* defined HAVE_MNTENT_H && defined HAVE_GETMNTENT_R */
-#ifndef PROXY
-# if defined(UDEVADM) || defined(UDEVSETTLE)
+#if defined(UDEVADM) || defined(UDEVSETTLE)
void virFileWaitForDevices(void)
{
-# ifdef UDEVADM
+# ifdef UDEVADM
const char *const settleprog[] = { UDEVADM, "settle", NULL };
-# else
+# else
const char *const settleprog[] = { UDEVSETTLE, NULL };
-# endif
+# endif
int exitstatus;
if (access(settleprog[0], X_OK) != 0)
@@ -2884,9 +2880,8 @@ void virFileWaitForDevices(void)
if (virRun(settleprog, &exitstatus) < 0)
{}
}
-# else
+#else
void virFileWaitForDevices(void) {}
-# endif
#endif
int virBuildPathInternal(char **path, ...)
diff --git a/src/xen/proxy_internal.c b/src/xen/proxy_internal.c
deleted file mode 100644
index 4033727..0000000
--- a/src/xen/proxy_internal.c
+++ /dev/null
@@ -1,1044 +0,0 @@
-/*
- * proxy_client.c: client side of the communication with the libvirt proxy.
- *
- * Copyright (C) 2006, 2008, 2009, 2010 Red Hat, Inc.
- *
- * See COPYING.LIB for the License of this software
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/poll.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <sys/wait.h>
-#include <string.h>
-
-#include "virterror_internal.h"
-#include "logging.h"
-#include "datatypes.h"
-#include "driver.h"
-#include "proxy_internal.h"
-#include "util.h"
-#include "xen_driver.h"
-#include "memory.h"
-
-#define STANDALONE
-
-#define VIR_FROM_THIS VIR_FROM_PROXY
-
-static int xenProxyClose(virConnectPtr conn);
-static virDrvOpenStatus xenProxyOpen(virConnectPtr conn, virConnectAuthPtr auth, int flags);
-static int xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer);
-static int xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info);
-static char *xenProxyGetCapabilities(virConnectPtr conn);
-static unsigned long xenProxyDomainGetMaxMemory(virDomainPtr domain);
-static int xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info);
-static char *xenProxyDomainGetOSType(virDomainPtr domain);
-
-struct xenUnifiedDriver xenProxyDriver = {
- xenProxyOpen, /* open */
- xenProxyClose, /* close */
- xenProxyGetVersion, /* version */
- NULL, /* hostname */
- xenProxyNodeGetInfo, /* nodeGetInfo */
- xenProxyGetCapabilities, /* getCapabilities */
- xenProxyListDomains, /* listDomains */
- xenProxyNumOfDomains, /* numOfDomains */
- NULL, /* domainCreateXML */
- NULL, /* domainSuspend */
- NULL, /* domainResume */
- NULL, /* domainShutdown */
- NULL, /* domainReboot */
- NULL, /* domainDestroy */
- xenProxyDomainGetOSType, /* domainGetOSType */
- xenProxyDomainGetMaxMemory, /* domainGetMaxMemory */
- NULL, /* domainSetMaxMemory */
- NULL, /* domainSetMemory */
- xenProxyDomainGetInfo, /* domainGetInfo */
- NULL, /* domainSave */
- NULL, /* domainRestore */
- NULL, /* domainCoreDump */
- NULL, /* domainPinVcpu */
- NULL, /* domainGetVcpus */
- NULL, /* listDefinedDomains */
- NULL, /* numOfDefinedDomains */
- NULL, /* domainCreate */
- NULL, /* domainDefineXML */
- NULL, /* domainUndefine */
- NULL, /* domainAttachDeviceFlags */
- NULL, /* domainDetachDeviceFlags */
- NULL, /* domainUpdateDeviceFlags */
- NULL, /* domainGetAutostart */
- NULL, /* domainSetAutostart */
- NULL, /* domainGetSchedulerType */
- NULL, /* domainGetSchedulerParameters */
- NULL, /* domainSetSchedulerParameters */
-};
-
-
-/************************************************************************
- * *
- * Error handling *
- * *
- ************************************************************************/
-
-#define virProxyError(code, ...) \
- virReportErrorHelper(NULL, VIR_FROM_PROXY, code, __FILE__, \
- __FUNCTION__, __LINE__, __VA_ARGS__)
-
-/************************************************************************
- * *
- * Automatic startup of the proxy server if it is not running *
- * *
- ************************************************************************/
-/**
- * virProxyFindServerPath:
- *
- * Tries to find the path to the gam_server binary.
- *
- * Returns path on success or NULL in case of error.
- */
-static const char *
-virProxyFindServerPath(void)
-{
- static const char *serverPaths[] = {
- BINDIR "/libvirt_proxy",
- "/usr/bin/libvirt_proxy_dbg",
- NULL
- };
- int i;
- const char *debugProxy = getenv("LIBVIRT_DEBUG_PROXY");
-
- if (debugProxy)
- return(debugProxy);
-
- for (i = 0; serverPaths[i]; i++) {
- if (access(serverPaths[i], X_OK | R_OK) == 0) {
- return serverPaths[i];
- }
- }
- return NULL;
-}
-
-/**
- * virProxyForkServer:
- *
- * Forks and try to launch the proxy server processing the requests for
- * libvirt when communicating with Xen.
- *
- * Returns 0 in case of success or -1 in case of detected error.
- */
-static int
-virProxyForkServer(void)
-{
- const char *proxyPath = virProxyFindServerPath();
- pid_t pid;
- const char *proxyarg[2];
-
- if (!proxyPath) {
- VIR_WARN0("failed to find libvirt_proxy");
- return(-1);
- }
-
- VIR_DEBUG("Asking to launch %s", proxyPath);
-
- proxyarg[0] = proxyPath;
- proxyarg[1] = NULL;
-
- if (virExecDaemonize(proxyarg, NULL, NULL,
- &pid, -1, NULL, NULL, 0,
- NULL, NULL, NULL) < 0)
- VIR_ERROR0(_("Failed to fork libvirt_proxy"));
-
- return (0);
-}
-
-/************************************************************************
- * *
- * Processing of client sockets *
- * *
- ************************************************************************/
-
-/**
- * virProxyOpenClientSocket:
- * @path: the filename for the socket
- *
- * try to connect to the socket open by libvirt_proxy
- *
- * Returns the associated file descriptor or -1 in case of failure
- */
-static int
-virProxyOpenClientSocket(const char *path) {
- int fd;
- struct sockaddr_un addr;
- int trials = 0;
-
-retry:
- fd = socket(PF_UNIX, SOCK_STREAM, 0);
- if (fd < 0) {
- return(-1);
- }
-
- /*
- * Abstract socket do not hit the filesystem, way more secure and
- * guaranteed to be atomic
- */
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_UNIX;
- addr.sun_path[0] = '\0';
- if (virStrcpy(&addr.sun_path[1], path, sizeof(addr.sun_path) - 1) == NULL) {
- close(fd);
- return -1;
- }
-
- /*
- * now bind the socket to that address and listen on it
- */
- if (connect(fd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
- close(fd);
- if (trials < 3) {
- if (virProxyForkServer() < 0)
- return(-1);
- trials++;
- usleep(5000 * trials * trials);
- goto retry;
- }
- return (-1);
- }
-
- DEBUG("connected to unix socket %s via %d", path, fd);
-
- return (fd);
-}
-
-/**
- * virProxyCloseSocket:
- * @priv: the Xen proxy data
- *
- * Close the socket from that client. The caller must
- * hold the lock on 'priv' before calling
- *
- * Returns 0 in case of success and -1 in case of error
- */
-static int
-virProxyCloseSocket(xenUnifiedPrivatePtr priv) {
- int ret;
-
- if (priv->proxy < 0)
- return(-1);
-
- ret = close(priv->proxy);
- if (ret != 0)
- VIR_WARN("Failed to close socket %d", priv->proxy);
- else
- VIR_DEBUG("Closed socket %d", priv->proxy);
- priv->proxy = -1;
- return(ret);
-}
-
-/**
- * virProxyReadClientSocket:
- * @fd: the socket
- * @buffer: the target memory area
- * @len: the length in bytes
- *
- * Process a read from a client socket
- *
- * Returns the number of byte read or -1 in case of error.
- */
-static int
-virProxyReadClientSocket(int fd, char *buffer, int len) {
- int ret;
-
- if ((fd < 0) || (buffer == NULL) || (len < 0))
- return(-1);
-
-retry:
- ret = read(fd, buffer, len);
- if (ret < 0) {
- if (errno == EINTR) {
- VIR_DEBUG("read socket %d interrupted", fd);
- goto retry;
- }
- VIR_WARN("Failed to read socket %d", fd);
- return(-1);
- }
-
- VIR_DEBUG("read %d bytes from socket %d",
- ret, fd);
- return(ret);
-}
-
-/**
- * virProxyWriteClientSocket:
- * @fd: the socket
- * @data: the data
- * @len: the length of data in bytes
- *
- * Process a read from a client socket
- */
-static int
-virProxyWriteClientSocket(int fd, const char *data, int len) {
- int ret;
-
- if ((fd < 0) || (data == NULL) || (len < 0))
- return(-1);
-
- ret = safewrite(fd, data, len);
- if (ret < 0) {
- VIR_WARN("Failed to write to socket %d", fd);
- return(-1);
- }
- VIR_DEBUG("wrote %d bytes to socket %d",
- len, fd);
-
- return(0);
-}
-
-/************************************************************************
- * *
- * Proxy commands processing *
- * *
- ************************************************************************/
-
-/**
- * xenProxyClose:
- * @conn: pointer to the hypervisor connection
- *
- * Shutdown the Xen proxy communication layer
- */
-static int
-xenProxyClose(virConnectPtr conn)
-{
- xenUnifiedPrivatePtr priv;
-
- if (conn == NULL) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return -1;
- }
-
- priv = (xenUnifiedPrivatePtr) conn->privateData;
- if (!priv) {
- virProxyError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
- return -1;
- }
-
- xenUnifiedLock(priv);
- virProxyCloseSocket (priv);
- xenUnifiedUnlock(priv);
-
- return 0;
-}
-
-static int ATTRIBUTE_NONNULL(2)
-xenProxyCommand(virConnectPtr conn, virProxyPacketPtr request,
- virProxyFullPacketPtr answer, int quiet) {
- static int serial = 0;
- int ret;
- virProxyPacketPtr res = NULL;
- xenUnifiedPrivatePtr priv;
-
- if (conn == NULL) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return -1;
- }
-
- priv = (xenUnifiedPrivatePtr) conn->privateData;
- if (!priv) {
- virProxyError(VIR_ERR_INTERNAL_ERROR, __FUNCTION__);
- return -1;
- }
-
- xenUnifiedLock(priv);
-
- /* Fail silently. */
- if (priv->proxy == -1)
- goto error;
-
- /*
- * normal communication serial numbers are in 0..4095
- */
- ++serial;
- if (serial >= 4096)
- serial = 0;
- request->version = PROXY_PROTO_VERSION;
- request->serial = serial;
- ret = virProxyWriteClientSocket(priv->proxy, (const char *) request,
- request->len);
- if (ret < 0) {
- if (!quiet)
- virReportSystemError(errno, "%s",
- _("failed to write proxy request"));
- goto error;
- }
-retry:
- if (answer == NULL) {
- /* read in situ */
- ret = virProxyReadClientSocket(priv->proxy, (char *) request,
- sizeof(virProxyPacket));
- if (ret < 0) {
- if (!quiet)
- virReportSystemError(errno, "%s",
- _("failed to read proxy reply"));
- goto error;
- }
- if (ret != sizeof(virProxyPacket)) {
- virProxyError(VIR_ERR_INTERNAL_ERROR,
- _("Communication error with proxy: got %d bytes of %d"),
- ret, (int) sizeof(virProxyPacket));
- goto error;
- }
- res = request;
- if (res->len != sizeof(virProxyPacket)) {
- virProxyError(VIR_ERR_INTERNAL_ERROR,
- _("Communication error with proxy: expected %d bytes got %d"),
- (int) sizeof(virProxyPacket), res->len);
- goto error;
- }
- } else {
- /* read in packet provided */
- ret = virProxyReadClientSocket(priv->proxy, (char *) answer,
- sizeof(virProxyPacket));
- if (ret < 0) {
- if (!quiet)
- virReportSystemError(errno, "%s",
- _("failed to read proxy reply"));
- goto error;
- }
- if (ret != sizeof(virProxyPacket)) {
- virProxyError(VIR_ERR_INTERNAL_ERROR,
- _("Communication error with proxy: got %d bytes of %d"),
- ret, (int) sizeof(virProxyPacket));
- goto error;
- }
- res = (virProxyPacketPtr) answer;
- if ((res->len < sizeof(virProxyPacket)) ||
- (res->len > sizeof(virProxyFullPacket))) {
- virProxyError(VIR_ERR_INTERNAL_ERROR,
- _("Communication error with proxy: got %d bytes packet"),
- res->len);
- goto error;
- }
- if (res->len > sizeof(virProxyPacket)) {
- ret = virProxyReadClientSocket(priv->proxy,
- (char *) &(answer->extra.arg[0]),
- res->len - ret);
- if (ret != (int) (res->len - sizeof(virProxyPacket))) {
- virProxyError(VIR_ERR_INTERNAL_ERROR,
- _("Communication error with proxy: got %d bytes of %d"),
- ret, (int) sizeof(virProxyPacket));
- goto error;
- }
- }
- }
- /*
- * do more checks on the incoming packet.
- */
- if ((res->version != PROXY_PROTO_VERSION) ||
- (res->len < sizeof(virProxyPacket))) {
- virProxyError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("Communication error with proxy: malformed packet"));
- goto error;
- }
- if (res->serial != serial) {
- VIR_WARN("got asynchronous packet number %d", res->serial);
- goto retry;
- }
-
- xenUnifiedUnlock(priv);
- return 0;
-
-error:
- virProxyCloseSocket(priv);
- xenUnifiedUnlock(priv);
- return -1;
-}
-
-/**
- * xenProxyOpen:
- * @conn: pointer to the hypervisor connection
- * @name: URL for the target, NULL for local
- * @flags: combination of virDrvOpenFlag(s)
- *
- * Try to initialize the Xen proxy communication layer
- * This can be opened only for a read-only kind of access
- *
- * Returns 0 in case of success, and -1 in case of failure
- */
-virDrvOpenStatus
-xenProxyOpen(virConnectPtr conn,
- virConnectAuthPtr auth ATTRIBUTE_UNUSED,
- int flags)
-{
- virProxyPacket req;
- int ret;
- int fd;
- xenUnifiedPrivatePtr priv;
-
- if (!(flags & VIR_CONNECT_RO))
- return(-1);
-
- priv = (xenUnifiedPrivatePtr) conn->privateData;
- priv->proxy = -1;
-
- fd = virProxyOpenClientSocket(PROXY_SOCKET_PATH);
- if (fd < 0) {
- virProxyError(VIR_ERR_NO_XEN, PROXY_SOCKET_PATH);
- return(-1);
- }
- priv->proxy = fd;
-
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_NONE;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, NULL, 1);
- if ((ret < 0) || (req.command != VIR_PROXY_NONE)) {
- virProxyError(VIR_ERR_OPERATION_FAILED, __FUNCTION__);
- return(-1);
- }
- return(0);
-}
-
-/************************************************************************
- * *
- * Driver entry points *
- * *
- ************************************************************************/
-
-/**
- * xenProxyGetVersion:
- * @conn: pointer to the Xen Daemon block
- * @hvVer: return value for the version of the running hypervisor (OUT)
- *
- * Get the version level of the Hypervisor running.
- *
- * Returns -1 in case of error, 0 otherwise. if the version can't be
- * extracted by lack of capacities returns 0 and @hvVer is 0, otherwise
- * @hvVer value is major * 1,000,000 + minor * 1,000 + release
- */
-static int
-xenProxyGetVersion(virConnectPtr conn, unsigned long *hvVer)
-{
- virProxyPacket req;
- int ret;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
- if (hvVer == NULL) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_VERSION;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, NULL, 0);
- if (ret < 0) {
- return(-1);
- }
- *hvVer = req.data.larg;
- return(0);
-}
-
-/**
- * xenProxyListDomains:
- * @conn: pointer to the hypervisor connection
- * @ids: array to collect the list of IDs of active domains
- * @maxids: size of @ids
- *
- * Collect the list of active domains, and store their ID in @maxids
- *
- * Returns the number of domain found or -1 in case of error
- */
-int
-xenProxyListDomains(virConnectPtr conn, int *ids, int maxids)
-{
- virProxyPacket req;
- virProxyFullPacket ans;
- int ret;
- int nb;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
- if ((ids == NULL) || (maxids <= 0)) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_LIST;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, &ans, 0);
- if (ret < 0) {
- return(-1);
- }
- nb = ans.data.arg;
- if ((nb > 1020) || (nb <= 0) ||
- (ans.len <= sizeof(virProxyPacket)) ||
- (ans.len > sizeof(virProxyFullPacket))) {
- virProxyError(VIR_ERR_OPERATION_FAILED, __FUNCTION__);
- return(-1);
- }
- if (nb > maxids)
- nb = maxids;
- memmove(ids, &ans.extra.arg[0], nb * sizeof(int));
-
- return(nb);
-}
-
-/**
- * xenProxyNumOfDomains:
- * @conn: pointer to the hypervisor connection
- *
- * Provides the number of active domains.
- *
- * Returns the number of domain found or -1 in case of error
- */
-int
-xenProxyNumOfDomains(virConnectPtr conn)
-{
- virProxyPacket req;
- int ret;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_NUM_DOMAIN;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, NULL, 0);
- if (ret < 0) {
- return(-1);
- }
- return(req.data.arg);
-}
-
-
-/**
- * xenProxyDomainGetDomMaxMemory:
- * @conn: pointer to the hypervisor connection
- * @id: the domain ID number
- *
- * Ask the Xen Daemon for the maximum memory allowed for a domain
- *
- * Returns the memory size in kilobytes or 0 in case of error.
- */
-static unsigned long
-xenProxyDomainGetDomMaxMemory(virConnectPtr conn, int id)
-{
- virProxyPacket req;
- int ret;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (0);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_MAX_MEMORY;
- req.data.arg = id;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, NULL, 0);
- if (ret < 0) {
- return(0);
- }
- return(req.data.larg);
-}
-
-/**
- * xenProxyDomainGetMaxMemory:
- * @domain: pointer to the domain block
- *
- * Ask the Xen Daemon for the maximum memory allowed for a domain
- *
- * Returns the memory size in kilobytes or 0 in case of error.
- */
-static unsigned long
-xenProxyDomainGetMaxMemory(virDomainPtr domain)
-{
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virProxyError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (0);
- }
- if (domain->id < 0)
- return (0);
- return(xenProxyDomainGetDomMaxMemory(domain->conn, domain->id));
-}
-
-/**
- * xenProxyDomainGetInfo:
- * @domain: a domain object
- * @info: pointer to a virDomainInfo structure allocated by the user
- *
- * This method looks up information about a domain and update the
- * information block provided.
- *
- * Returns 0 in case of success, -1 in case of error
- */
-static int
-xenProxyDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
-{
- virProxyPacket req;
- virProxyFullPacket ans;
- int ret;
-
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virProxyError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (-1);
- }
- if (domain->id < 0)
- return (-1);
- if (info == NULL) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_DOMAIN_INFO;
- req.data.arg = domain->id;
- req.len = sizeof(req);
- ret = xenProxyCommand(domain->conn, &req, &ans, 0);
- if (ret < 0) {
- return(-1);
- }
- if (ans.len != sizeof(virProxyPacket) + sizeof(virDomainInfo)) {
- virProxyError(VIR_ERR_OPERATION_FAILED, __FUNCTION__);
- return (-1);
- }
- memmove(info, &ans.extra.dinfo, sizeof(virDomainInfo));
-
- return(0);
-}
-
-/**
- * xenProxyLookupByID:
- * @conn: pointer to the hypervisor connection
- * @id: the domain ID number
- *
- * Try to find a domain based on the hypervisor ID number
- *
- * Returns a new domain object or NULL in case of failure
- */
-virDomainPtr
-xenProxyLookupByID(virConnectPtr conn, int id)
-{
- virProxyPacket req;
- virProxyFullPacket ans;
- unsigned char uuid[VIR_UUID_BUFLEN];
- const char *name;
- int ret;
- virDomainPtr res;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (NULL);
- }
- if (id < 0) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_LOOKUP_ID;
- req.data.arg = id;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, &ans, 0);
- if (ret < 0) {
- return(NULL);
- }
- if (ans.data.arg == -1) {
- return(NULL);
- }
- memcpy(uuid, &ans.extra.str[0], VIR_UUID_BUFLEN);
- name = &ans.extra.str[VIR_UUID_BUFLEN];
- res = virGetDomain(conn, name, uuid);
- if (res) res->id = id;
- return(res);
-}
-
-/**
- * xenProxyLookupByUUID:
- * @conn: pointer to the hypervisor connection
- * @uuid: the raw UUID for the domain
- *
- * Try to lookup a domain on xend based on its UUID.
- *
- * Returns a new domain object or NULL in case of failure
- */
-virDomainPtr
-xenProxyLookupByUUID(virConnectPtr conn, const unsigned char *uuid)
-{
- virProxyFullPacket req;
- const char *name;
- int ret;
- virDomainPtr res;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (NULL);
- }
- if (uuid == NULL) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
- memset(&req, 0, sizeof(virProxyPacket));
- req.command = VIR_PROXY_LOOKUP_UUID;
- req.len = sizeof(virProxyPacket) + VIR_UUID_BUFLEN;
- memcpy(&req.extra.str[0], uuid, VIR_UUID_BUFLEN);
-
- ret = xenProxyCommand(conn, (virProxyPacketPtr) &req, &req, 0);
- if (ret < 0) {
- return(NULL);
- }
- if (req.data.arg == -1) {
- return(NULL);
- }
- name = &req.extra.str[0];
- res = virGetDomain(conn, name, uuid);
- if (res) res->id = req.data.arg;
- return(res);
-}
-
-/**
- * xenProxyLookupByName:
- * @conn: A xend instance
- * @name: The name of the domain
- *
- * This method looks up information about a domain based on its name
- *
- * Returns a new domain object or NULL in case of failure
- */
-virDomainPtr
-xenProxyLookupByName(virConnectPtr conn, const char *name)
-{
- virProxyFullPacket req;
- int ret, len;
- virDomainPtr res;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (NULL);
- }
- if (name == NULL) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
- len = strlen(name);
- if (len > 1000) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (NULL);
- }
- memset(&req, 0, sizeof(virProxyPacket));
- req.command = VIR_PROXY_LOOKUP_NAME;
- req.len = sizeof(virProxyPacket) + len + 1;
- strcpy(&req.extra.str[0], name);
- ret = xenProxyCommand(conn, (virProxyPacketPtr) &req, &req, 0);
- if (ret < 0) {
- return(NULL);
- }
- if (req.data.arg == -1) {
- return(NULL);
- }
- res = virGetDomain(conn, name, (const unsigned char *)&req.extra.str[0]);
- if (res) res->id = req.data.arg;
- return(res);
-}
-
-/**
- * xenProxyNodeGetInfo:
- * @conn: pointer to the Xen Daemon block
- * @info: pointer to a virNodeInfo structure allocated by the user
- *
- * Extract hardware information about the node.
- *
- * Returns 0 in case of success and -1 in case of failure.
- */
-static int
-xenProxyNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) {
- virProxyPacket req;
- virProxyFullPacket ans;
- int ret;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return (-1);
- }
- if (info == NULL) {
- virProxyError(VIR_ERR_INVALID_ARG, __FUNCTION__);
- return (-1);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_NODE_INFO;
- req.data.arg = 0;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, &ans, 0);
- if (ret < 0) {
- return(-1);
- }
- if (ans.data.arg == -1) {
- return(-1);
- }
- if (ans.len != sizeof(virProxyPacket) + sizeof(virNodeInfo)) {
- return(-1);
- }
- memcpy(info, &ans.extra.ninfo, sizeof(virNodeInfo));
- return(0);
-}
-
-/**
- * xenProxyGetCapabilities:
- * @conn: pointer to the Xen Daemon block
- *
- * Extract capabilities of the hypervisor.
- *
- * Returns capabilities in case of success (freed by caller)
- * and NULL in case of failure.
- */
-static char *
-xenProxyGetCapabilities (virConnectPtr conn)
-{
- virProxyPacket req;
- virProxyFullPacket ans;
- int ret, xmllen;
- char *xml;
-
- if (!VIR_IS_CONNECT(conn)) {
- virProxyError(VIR_ERR_INVALID_CONN, __FUNCTION__);
- return NULL;
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_GET_CAPABILITIES;
- req.data.arg = 0;
- req.len = sizeof(req);
- ret = xenProxyCommand(conn, &req, &ans, 0);
- if (ret < 0) {
- return NULL;
- }
- if (ans.data.arg == -1)
- return NULL;
- if (ans.len <= sizeof(virProxyPacket)
- || ans.len > sizeof (ans) - sizeof(virProxyPacket)) {
- virProxyError(VIR_ERR_OPERATION_FAILED, __FUNCTION__);
- return NULL;
- }
-
- xmllen = ans.len - sizeof (virProxyPacket);
- if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
- virReportOOMError();
- return NULL;
- }
- memcpy (xml, ans.extra.str, xmllen);
- xml[xmllen] = '\0';
-
- return xml;
-}
-
-/**
- * xenProxyDomainDumpXML:
- * @domain: a domain object
- * @flags: xml generation flags
- *
- * This method generates an XML description of a domain.
- *
- * Returns the XML document on success, NULL otherwise.
- */
-char *
-xenProxyDomainDumpXML(virDomainPtr domain, int flags ATTRIBUTE_UNUSED)
-{
- virProxyPacket req;
- virProxyFullPacket ans;
- int ret;
- int xmllen;
- char *xml;
-
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virProxyError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (NULL);
- }
- if (domain->id < 0)
- return (NULL);
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_DOMAIN_XML;
- req.data.arg = domain->id;
- req.len = sizeof(req);
- ret = xenProxyCommand(domain->conn, &req, &ans, 0);
- if (ret < 0) {
- return(NULL);
- }
- if (ans.len <= sizeof(virProxyPacket)
- || ans.len > sizeof (ans) - sizeof(virProxyPacket)) {
- virProxyError(VIR_ERR_OPERATION_FAILED, __FUNCTION__);
- return (NULL);
- }
- xmllen = ans.len - sizeof(virProxyPacket);
- if (VIR_ALLOC_N(xml, xmllen+1) < 0) {
- virReportOOMError();
- return NULL;
- }
- memcpy(xml, &ans.extra.dinfo, xmllen);
- xml[xmllen] = '\0';
-
- return(xml);
-}
-
-/**
- * xenProxyDomainGetOSType:
- * @domain: a domain object
- *
- * Get the type of domain operation system.
- *
- * Returns the new string or NULL in case of error, the string must be
- * freed by the caller.
- */
-static char *
-xenProxyDomainGetOSType(virDomainPtr domain)
-{
- virProxyPacket req;
- virProxyFullPacket ans;
- int ret;
- int oslen;
- char *ostype;
-
- if (!VIR_IS_CONNECTED_DOMAIN(domain)) {
- virProxyError(VIR_ERR_INVALID_DOMAIN, __FUNCTION__);
- return (NULL);
- }
- memset(&req, 0, sizeof(req));
- req.command = VIR_PROXY_DOMAIN_OSTYPE;
- req.data.arg = domain->id;
- req.len = sizeof(req);
- ret = xenProxyCommand(domain->conn, &req, &ans, 0);
- if (ret < 0) {
- return(NULL);
- }
- if ((ans.len == sizeof(virProxyPacket)) && (ans.data.arg < 0)) {
- virRaiseError (domain->conn, NULL, NULL, VIR_FROM_REMOTE,
- VIR_ERR_OPERATION_FAILED, VIR_ERR_ERROR, NULL, NULL,
- NULL, 0, 0, "%s", _("Cannot get domain details"));
- return(NULL);
- }
-
- if (ans.len <= sizeof(virProxyPacket)
- || ans.len > sizeof (ans) - sizeof(virProxyPacket)) {
- virProxyError(VIR_ERR_OPERATION_FAILED, __FUNCTION__);
- return (NULL);
- }
- oslen = ans.len - sizeof(virProxyPacket);
- if (VIR_ALLOC_N(ostype, oslen+1) < 0) {
- virReportOOMError();
- return NULL;
- }
- memcpy(ostype, &ans.extra.dinfo, oslen);
- ostype[oslen] = '\0';
-
- return(ostype);
-}
diff --git a/src/xen/proxy_internal.h b/src/xen/proxy_internal.h
deleted file mode 100644
index f822473..0000000
--- a/src/xen/proxy_internal.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * proxy.h: common definitions for proxy usage
- *
- * Copyright (C) 2006 Red Hat, Inc.
- *
- * See COPYING.LIB for the License of this software
- *
- * Daniel Veillard <veillard(a)redhat.com>
- */
-
-
-#ifndef __LIBVIR_PROXY_H__
-# define __LIBVIR_PROXY_H__
-
-# include "internal.h"
-
-# define PROXY_SOCKET_PATH "/tmp/livirt_proxy_conn"
-# define PROXY_PROTO_VERSION 1
-
-/*
- * the command allowed though the proxy
- */
-typedef enum {
- VIR_PROXY_NONE = 0,
- VIR_PROXY_VERSION = 1,
- VIR_PROXY_NODE_INFO = 2,
- VIR_PROXY_LIST = 3,
- VIR_PROXY_NUM_DOMAIN = 4,
- VIR_PROXY_LOOKUP_ID = 5,
- VIR_PROXY_LOOKUP_UUID = 6,
- VIR_PROXY_LOOKUP_NAME = 7,
- VIR_PROXY_MAX_MEMORY = 8,
- VIR_PROXY_DOMAIN_INFO = 9,
- VIR_PROXY_DOMAIN_XML = 10,
- VIR_PROXY_DOMAIN_OSTYPE = 11,
- VIR_PROXY_GET_CAPABILITIES = 12
-} virProxyCommand;
-
-/*
- * structure used by the client to make a request to the proxy
- * and by the proxy when answering the client.
- * the size may not be fixed, it's passed as len.
- */
-struct _virProxyPacket {
- unsigned short version; /* version of the proxy protocol */
- unsigned short command; /* command number a virProxyCommand */
- unsigned short serial; /* command serial number */
- unsigned short len; /* the length of the request */
- union {
- char string[8]; /* string data */
- int arg; /* or int argument */
- long larg; /* or long argument */
- } data;
-};
-typedef struct _virProxyPacket virProxyPacket;
-typedef virProxyPacket *virProxyPacketPtr;
-
-/*
- * If there is extra data sent from the proxy to the client,
- * they are appended after the packet.
- * the size may not be fixed, it's passed as len and includes the
- * extra data.
- */
-struct _virProxyFullPacket {
- unsigned short version; /* version of the proxy protocol */
- unsigned short command; /* command number a virProxyCommand */
- unsigned short serial; /* command serial number */
- unsigned short len; /* the length of the request */
- union {
- char string[8]; /* string data */
- int arg; /* or int argument */
- long larg; /* or long argument */
- } data;
- /* that should be aligned on a 16bytes boundary */
- union {
- char str[4080]; /* extra char array */
- int arg[1020]; /* extra int array */
- virDomainInfo dinfo; /* domain information */
- virNodeInfo ninfo; /* node information */
- } extra;
-};
-typedef struct _virProxyFullPacket virProxyFullPacket;
-typedef virProxyFullPacket *virProxyFullPacketPtr;
-
-/* xen_unified makes direct calls or indirect calls through here. */
-extern struct xenUnifiedDriver xenProxyDriver;
-extern int xenProxyInit (void);
-
-extern virDomainPtr xenProxyLookupByID(virConnectPtr conn, int id);
-extern virDomainPtr xenProxyLookupByUUID(virConnectPtr conn,
- const unsigned char *uuid);
-extern virDomainPtr xenProxyLookupByName(virConnectPtr conn,
- const char *domname);
-
-extern char * xenProxyDomainDumpXML(virDomainPtr domain,
- int flags);
-extern int xenProxyListDomains(virConnectPtr conn, int *ids,
- int maxids);
-extern int xenProxyNumOfDomains(virConnectPtr conn);
-#endif /* __LIBVIR_PROXY_H__ */
diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c
index 66e8518..f126f0d 100644
--- a/src/xen/xen_driver.c
+++ b/src/xen/xen_driver.c
@@ -13,7 +13,7 @@
/* Note:
*
* This driver provides a unified interface to the five
- * separate underlying Xen drivers (xen_internal, proxy_internal,
+ * separate underlying Xen drivers (xen_internal,
* xend_internal, xs_internal and xm_internal). Historically
* the body of libvirt.c handled the five Xen drivers,
* and contained Xen-specific code.
@@ -33,7 +33,6 @@
#include "xen_driver.h"
#include "xen_hypervisor.h"
-#include "proxy_internal.h"
#include "xend_internal.h"
#include "xs_internal.h"
#include "xm_internal.h"
@@ -61,7 +60,6 @@ xenUnifiedDomainGetVcpus (virDomainPtr dom,
/* The five Xen drivers below us. */
static struct xenUnifiedDriver const * const drivers[XEN_UNIFIED_NR_DRIVERS] = {
[XEN_UNIFIED_HYPERVISOR_OFFSET] = &xenHypervisorDriver,
- [XEN_UNIFIED_PROXY_OFFSET] = &xenProxyDriver,
[XEN_UNIFIED_XEND_OFFSET] = &xenDaemonDriver,
[XEN_UNIFIED_XS_OFFSET] = &xenStoreDriver,
[XEN_UNIFIED_XM_OFFSET] = &xenXMDriver,
@@ -318,7 +316,6 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
priv->handle = -1;
priv->xendConfigVersion = -1;
priv->xshandle = NULL;
- priv->proxy = -1;
/* Hypervisor is only run with privilege & required to succeed */
@@ -331,9 +328,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
}
}
- /* XenD is required to succeed if privileged.
- * If it fails as non-root, then the proxy driver may take over
- */
+ /* XenD is required to succeed if privileged */
DEBUG0("Trying XenD sub-driver");
if (drivers[XEN_UNIFIED_XEND_OFFSET]->open(conn, auth, flags) ==
VIR_DRV_OPEN_SUCCESS) {
@@ -363,20 +358,9 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
if (xenHavePrivilege()) {
goto fail; /* XenD is mandatory when privileged */
} else {
-#if WITH_PROXY
- DEBUG0("Trying proxy sub-driver");
- if (drivers[XEN_UNIFIED_PROXY_OFFSET]->open(conn, auth, flags) ==
- VIR_DRV_OPEN_SUCCESS) {
- DEBUG0("Activated proxy sub-driver");
- priv->opened[XEN_UNIFIED_PROXY_OFFSET] = 1;
- } else {
- goto fail; /* Proxy is mandatory if XenD failed */
- }
-#else
DEBUG0("Handing off for remote driver");
ret = VIR_DRV_OPEN_DECLINED; /* Let remote_driver try instead */
goto clean;
-#endif
}
}
@@ -402,9 +386,7 @@ xenUnifiedOpen (virConnectPtr conn, virConnectAuthPtr auth, int flags)
fail:
ret = VIR_DRV_OPEN_ERROR;
-#ifndef WITH_PROXY
clean:
-#endif
DEBUG0("Failed to activate a mandatory sub-driver");
for (i = 0 ; i < XEN_UNIFIED_NR_DRIVERS ; i++)
if (priv->opened[i]) drivers[i]->close(conn);
@@ -579,11 +561,6 @@ xenUnifiedListDomains (virConnectPtr conn, int *ids, int maxids)
if (ret >= 0) return ret;
}
- /* Try proxy. */
- if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
- ret = xenProxyListDomains (conn, ids, maxids);
- if (ret >= 0) return ret;
- }
return -1;
}
@@ -611,12 +588,6 @@ xenUnifiedNumOfDomains (virConnectPtr conn)
if (ret >= 0) return ret;
}
- /* Try proxy. */
- if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
- ret = xenProxyNumOfDomains (conn);
- if (ret >= 0) return ret;
- }
-
return -1;
}
@@ -659,13 +630,6 @@ xenUnifiedDomainLookupByID (virConnectPtr conn, int id)
return ret;
}
- /* Try proxy. */
- if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
- ret = xenProxyLookupByID (conn, id);
- if (ret || conn->err.code != VIR_ERR_OK)
- return ret;
- }
-
/* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByID (conn, id);
@@ -697,13 +661,6 @@ xenUnifiedDomainLookupByUUID (virConnectPtr conn,
return ret;
}
- /* Try proxy. */
- if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
- ret = xenProxyLookupByUUID (conn, uuid);
- if (ret || conn->err.code != VIR_ERR_OK)
- return ret;
- }
-
/* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByUUID (conn, uuid);
@@ -735,13 +692,6 @@ xenUnifiedDomainLookupByName (virConnectPtr conn,
*/
virConnResetLastError (conn);
- /* Try proxy. */
- if (priv->opened[XEN_UNIFIED_PROXY_OFFSET]) {
- ret = xenProxyLookupByName (conn, name);
- if (ret || conn->err.code != VIR_ERR_OK)
- return ret;
- }
-
/* Try xend. */
if (priv->opened[XEN_UNIFIED_XEND_OFFSET]) {
ret = xenDaemonLookupByName (conn, name);
@@ -1223,8 +1173,6 @@ xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
VIR_FREE(cpus);
return(res);
}
- if (priv->opened[XEN_UNIFIED_PROXY_OFFSET])
- return xenProxyDomainDumpXML(dom, flags);
}
xenUnifiedError(VIR_ERR_NO_SUPPORT, __FUNCTION__);
diff --git a/src/xen/xen_driver.h b/src/xen/xen_driver.h
index 6af6132..58b8561 100644
--- a/src/xen/xen_driver.h
+++ b/src/xen/xen_driver.h
@@ -42,16 +42,15 @@
extern int xenRegister (void);
# define XEN_UNIFIED_HYPERVISOR_OFFSET 0
-# define XEN_UNIFIED_PROXY_OFFSET 1
-# define XEN_UNIFIED_XEND_OFFSET 2
-# define XEN_UNIFIED_XS_OFFSET 3
-# define XEN_UNIFIED_XM_OFFSET 4
+# define XEN_UNIFIED_XEND_OFFSET 1
+# define XEN_UNIFIED_XS_OFFSET 2
+# define XEN_UNIFIED_XM_OFFSET 3
# if WITH_XEN_INOTIFY
-# define XEN_UNIFIED_INOTIFY_OFFSET 5
-# define XEN_UNIFIED_NR_DRIVERS 6
-# else
+# define XEN_UNIFIED_INOTIFY_OFFSET 4
# define XEN_UNIFIED_NR_DRIVERS 5
+# else
+# define XEN_UNIFIED_NR_DRIVERS 4
# endif
# define MIN_XEN_GUEST_SIZE 64 /* 64 megabytes */
@@ -175,8 +174,6 @@ struct _xenUnifiedPrivate {
struct xs_handle *xshandle; /* handle to talk to the xenstore */
- int proxy; /* fd of proxy. */
-
/* A list of xenstore watches */
xenStoreWatchListPtr xsWatchList;
@@ -230,12 +227,7 @@ void xenUnifiedDomainEventDispatch (xenUnifiedPrivatePtr priv,
unsigned long xenUnifiedVersion(void);
int xenUnifiedGetMaxVcpus(virConnectPtr conn, const char *type);
-# ifndef PROXY
void xenUnifiedLock(xenUnifiedPrivatePtr priv);
void xenUnifiedUnlock(xenUnifiedPrivatePtr priv);
-# else
-# define xenUnifiedLock(p) do {} while(0)
-# define xenUnifiedUnlock(p) do {} while(0)
-# endif
#endif /* __VIR_XEN_UNIFIED_H__ */
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index ec726fe..c5cc880 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -748,11 +748,8 @@ typedef struct xen_op_v2_dom xen_op_v2_dom;
# error "unsupported platform"
#endif
-#ifndef PROXY
static unsigned long xenHypervisorGetMaxMemory(virDomainPtr domain);
-#endif
-#ifndef PROXY
struct xenUnifiedDriver xenHypervisorDriver = {
xenHypervisorOpen, /* open */
xenHypervisorClose, /* close */
@@ -792,15 +789,12 @@ struct xenUnifiedDriver xenHypervisorDriver = {
xenHypervisorGetSchedulerParameters, /* domainGetSchedulerParameters */
xenHypervisorSetSchedulerParameters, /* domainSetSchedulerParameters */
};
-#endif /* !PROXY */
#define virXenError(code, ...) \
if (in_init == 0) \
virReportErrorHelper(NULL, VIR_FROM_XEN, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
-#ifndef PROXY
-
/**
* virXenErrorFunc:
* @error: the error number
@@ -835,8 +829,6 @@ virXenErrorFunc(virErrorNumber error, const char *func, const char *info,
}
}
-#endif /* PROXY */
-
/**
* xenHypervisorDoV0Op:
* @handle: the handle to the Xen hypervisor
@@ -1103,7 +1095,6 @@ virXen_getdomaininfo(int handle, int first_domain,
}
-#ifndef PROXY
/**
* xenHypervisorGetSchedulerType:
* @domain: pointer to the Xen Hypervisor block
@@ -1419,7 +1410,7 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
const char *path,
struct _virDomainBlockStats *stats)
{
-# ifdef __linux__
+#ifdef __linux__
xenUnifiedPrivatePtr priv;
int ret;
@@ -1429,12 +1420,12 @@ xenHypervisorDomainBlockStats (virDomainPtr dom,
ret = xenLinuxDomainBlockStats (priv, dom, path, stats);
xenUnifiedUnlock(priv);
return ret;
-# else
+#else
virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__,
"block statistics not supported on this platform",
dom->id);
return -1;
-# endif
+#endif
}
/* Paths have the form vif<domid>.<n> (this interface checks that
@@ -1449,7 +1440,7 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
const char *path,
struct _virDomainInterfaceStats *stats)
{
-# ifdef __linux__
+#ifdef __linux__
int rqdomid, device;
/* Verify that the vif requested is one belonging to the current
@@ -1467,11 +1458,11 @@ xenHypervisorDomainInterfaceStats (virDomainPtr dom,
}
return linuxDomainInterfaceStats(path, stats);
-# else
+#else
virXenErrorFunc(VIR_ERR_NO_SUPPORT, __FUNCTION__,
"/proc/net/dev: Interface not found", 0);
return -1;
-# endif
+#endif
}
/**
@@ -1777,7 +1768,7 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
}
return(ret);
}
-#endif /* !PROXY*/
+
/**
* virXen_getvcpusinfo:
@@ -2810,7 +2801,6 @@ xenHypervisorListDomains(virConnectPtr conn, int *ids, int maxids)
}
-#ifndef PROXY
char *
xenHypervisorDomainGetOSType (virDomainPtr dom)
{
@@ -2982,7 +2972,6 @@ xenHypervisorLookupDomainByUUID(virConnectPtr conn,
VIR_FREE(name);
return ret;
}
-#endif
/**
* xenHypervisorGetMaxVcpus:
@@ -3044,7 +3033,6 @@ xenHypervisorGetDomMaxMemory(virConnectPtr conn, int id)
return((unsigned long) XEN_GETDOMAININFO_MAX_PAGES(dominfo) * kb_per_pages);
}
-#ifndef PROXY
/**
* xenHypervisorGetMaxMemory:
* @domain: a domain object or NULL
@@ -3069,7 +3057,6 @@ xenHypervisorGetMaxMemory(virDomainPtr domain)
return(xenHypervisorGetDomMaxMemory(domain->conn, domain->id));
}
-#endif
/**
* xenHypervisorGetDomInfo:
@@ -3181,7 +3168,6 @@ xenHypervisorGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
}
-#ifndef PROXY
/**
* xenHypervisorNodeGetCellsFreeMemory:
* @conn: pointer to the hypervisor connection
@@ -3371,9 +3357,8 @@ xenHypervisorSetMaxMemory(virDomainPtr domain, unsigned long memory)
return (-1);
return (0);
}
-#endif /* PROXY */
-#ifndef PROXY
+
/**
* xenHypervisorSetVcpus:
* @domain: pointer to domain object
@@ -3436,7 +3421,6 @@ xenHypervisorPinVcpu(virDomainPtr domain, unsigned int vcpu,
return (-1);
return (0);
}
-#endif
/**
* virDomainGetVcpus:
@@ -3457,7 +3441,6 @@ xenHypervisorPinVcpu(virDomainPtr domain, unsigned int vcpu,
*
* Returns the number of info filled in case of success, -1 in case of failure.
*/
-#ifndef PROXY
int
xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
unsigned char *cpumaps, int maplen)
@@ -3523,7 +3506,6 @@ xenHypervisorGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
}
return nbinfo;
}
-#endif /* PROXY */
/**
* xenHypervisorGetVcpuMax:
diff --git a/src/xen/xen_hypervisor.h b/src/xen/xen_hypervisor.h
index 7cc39db..6018b84 100644
--- a/src/xen/xen_hypervisor.h
+++ b/src/xen/xen_hypervisor.h
@@ -22,7 +22,6 @@ int xenHypervisorInit (void);
virCapsPtr xenHypervisorMakeCapabilities (virConnectPtr conn);
-/* The following calls are made directly by the Xen proxy: */
int
xenHypervisorHasDomain(virConnectPtr conn,
int id);
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 5c3a4bd..7cea493 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -51,15 +51,11 @@
#define VIR_FROM_THIS VIR_FROM_XEND
-#ifndef PROXY
-
/*
* The number of Xen scheduler parameters
*/
-# define XEN_SCHED_SEDF_NPARAM 6
-# define XEN_SCHED_CRED_NPARAM 2
-
-#endif /* PROXY */
+#define XEN_SCHED_SEDF_NPARAM 6
+#define XEN_SCHED_CRED_NPARAM 2
#ifdef WITH_RHEL5_API
# define XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU 0
@@ -71,7 +67,6 @@
#define XEND_RCV_BUF_MAX_LEN 65536
-#ifndef PROXY
static int
xenDaemonFormatSxprDisk(virConnectPtr conn ATTRIBUTE_UNUSED,
virDomainDiskDefPtr def,
@@ -97,7 +92,6 @@ virDomainXMLDevID(virDomainPtr domain,
char *class,
char *ref,
int ref_len);
-#endif
#define virXendError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_XEND, code, __FILE__, \
@@ -399,7 +393,6 @@ xend_get(virConnectPtr xend, const char *path,
return ret;
}
-#ifndef PROXY
/**
* xend_post:
* @xend: pointer to the Xen Daemon structure
@@ -460,7 +453,6 @@ xend_post(virConnectPtr xend, const char *path, const char *ops)
VIR_FREE(err_buf);
return ret;
}
-#endif /* ! PROXY */
/**
@@ -495,7 +487,6 @@ http2unix(int ret)
return -1;
}
-#ifndef PROXY
/**
* xend_op_ext:
* @xend: pointer to the Xen Daemon structure
@@ -570,7 +561,6 @@ xend_op(virConnectPtr xend, const char *name, const char *key, ...)
return ret;
}
-#endif /* ! PROXY */
/**
* sexpr_get:
@@ -698,7 +688,6 @@ sexpr_uuid(unsigned char *ptr, const struct sexpr *node, const char *path)
}
-#ifndef PROXY
/**
* urlencode:
* @string: the input URL
@@ -737,7 +726,6 @@ urlencode(const char *string)
return buffer;
}
-#endif /* ! PROXY */
/* PUBLIC FUNCTIONS */
@@ -779,7 +767,7 @@ xenDaemonOpen_unix(virConnectPtr conn, const char *path)
return (0);
}
-#ifndef PROXY
+
/**
* xenDaemonOpen_tcp:
* @conn: an existing virtual connection block
@@ -879,9 +867,6 @@ xend_wait_for_devices(virConnectPtr xend, const char *name)
}
-#endif /* PROXY */
-
-
/**
* xenDaemonListDomainsOld:
* @xend: pointer to the Xen Daemon block
@@ -946,7 +931,7 @@ xenDaemonListDomainsOld(virConnectPtr xend)
return ret;
}
-#ifndef PROXY
+
/**
* xenDaemonDomainCreateXML:
* @xend: A xend instance
@@ -983,7 +968,7 @@ xenDaemonDomainCreateXML(virConnectPtr xend, const char *sexpr)
return ret;
}
-#endif /* ! PROXY */
+
/**
* xenDaemonDomainLookupByName_ids:
@@ -1090,7 +1075,6 @@ error:
}
-#ifndef PROXY
static int
xend_detect_config_version(virConnectPtr conn) {
struct sexpr *root;
@@ -1121,7 +1105,6 @@ xend_detect_config_version(virConnectPtr conn) {
return (0);
}
-#endif /* PROXY */
/*****************************************************************
******
@@ -1767,9 +1750,7 @@ xenDaemonParseSxprGraphicsOld(virConnectPtr conn,
int hvm,
int xendConfigVersion)
{
-#ifndef PROXY
xenUnifiedPrivatePtr priv = conn->privateData;
-#endif
const char *tmp;
virDomainGraphicsDefPtr graphics = NULL;
@@ -1858,9 +1839,7 @@ xenDaemonParseSxprGraphicsNew(virConnectPtr conn,
virDomainDefPtr def,
const struct sexpr *root)
{
-#ifndef PROXY
xenUnifiedPrivatePtr priv = conn->privateData;
-#endif
virDomainGraphicsDefPtr graphics = NULL;
const struct sexpr *cur, *node;
const char *tmp;
@@ -2099,9 +2078,7 @@ xenDaemonParseSxpr(virConnectPtr conn,
int xendConfigVersion,
const char *cpus)
{
-#ifndef PROXY
xenUnifiedPrivatePtr priv = conn->privateData;
-#endif
const char *tmp;
virDomainDefPtr def;
int hvm = 0;
@@ -2624,7 +2601,6 @@ sexpr_to_xend_topology(const struct sexpr *root,
}
-#ifndef PROXY
/**
* sexpr_to_domain:
* @conn: an existing virtual connection block
@@ -2678,7 +2654,7 @@ error:
virUnrefDomain(ret);
return(NULL);
}
-#endif /* !PROXY */
+
/*****************************************************************
******
@@ -2691,7 +2667,6 @@ error:
******
******
*****************************************************************/
-#ifndef PROXY
/**
* xenDaemonOpen:
* @conn: an existing virtual connection block
@@ -3053,7 +3028,7 @@ xenDaemonDomainRestore(virConnectPtr conn, const char *filename)
}
return xend_op(conn, "", "op", "restore", "file", filename, NULL);
}
-#endif /* !PROXY */
+
/**
* xenDaemonDomainGetMaxMemory:
@@ -3091,7 +3066,7 @@ xenDaemonDomainGetMaxMemory(virDomainPtr domain)
return(ret);
}
-#ifndef PROXY
+
/**
* xenDaemonDomainSetMaxMemory:
* @domain: pointer to the Domain block
@@ -3161,7 +3136,6 @@ xenDaemonDomainSetMemory(virDomainPtr domain, unsigned long memory)
"target", buf, NULL);
}
-#endif /* ! PROXY */
virDomainDefPtr
xenDaemonDomainFetch(virConnectPtr conn,
@@ -3199,7 +3173,6 @@ cleanup:
}
-#ifndef PROXY
/**
* xenDaemonDomainDumpXML:
* @domain: a domain object
@@ -3241,7 +3214,7 @@ xenDaemonDomainDumpXML(virDomainPtr domain, int flags, const char *cpus)
return xml;
}
-#endif /* !PROXY */
+
/**
* xenDaemonDomainGetInfo:
@@ -3280,7 +3253,7 @@ xenDaemonDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info)
return (ret);
}
-#ifndef PROXY
+
/**
* xenDaemonLookupByName:
* @conn: A xend instance
@@ -3313,7 +3286,7 @@ error:
sexpr_free(root);
return(ret);
}
-#endif /* ! PROXY */
+
/**
* xenDaemonNodeGetInfo:
@@ -3420,7 +3393,7 @@ xenDaemonGetVersion(virConnectPtr conn, unsigned long *hvVer)
return(0);
}
-#ifndef PROXY
+
/**
* xenDaemonListDomains:
* @conn: pointer to the hypervisor connection
@@ -3500,9 +3473,8 @@ error:
sexpr_free(root);
return(ret);
}
-#endif /* ! PROXY */
-#ifndef PROXY
+
/**
* xenDaemonLookupByID:
* @conn: pointer to the hypervisor connection
@@ -6130,5 +6102,3 @@ virDomainXMLDevID(virDomainPtr domain,
return 0;
}
-
-#endif /* ! PROXY */
diff --git a/src/xen/xs_internal.c b/src/xen/xs_internal.c
index eba1b95..2693b6e 100644
--- a/src/xen/xs_internal.c
+++ b/src/xen/xs_internal.c
@@ -38,7 +38,6 @@
#define VIR_FROM_THIS VIR_FROM_XEN
-#ifndef PROXY
static char *xenStoreDomainGetOSType(virDomainPtr domain);
static void xenStoreWatchEvent(int watch, int fd, int events, void *data);
static void xenStoreWatchListFree(xenStoreWatchListPtr list);
@@ -83,8 +82,6 @@ struct xenUnifiedDriver xenStoreDriver = {
NULL, /* domainSetSchedulerParameters */
};
-#endif /* ! PROXY */
-
#define virXenStoreError(code, ...) \
virReportErrorHelper(NULL, VIR_FROM_XENSTORE, code, __FILE__, \
__FUNCTION__, __LINE__, __VA_ARGS__)
@@ -94,7 +91,6 @@ struct xenUnifiedDriver xenStoreDriver = {
* Helper internal APIs *
* *
************************************************************************/
-#ifndef PROXY
/**
* virConnectDoStoreList:
* @conn: pointer to the hypervisor connection
@@ -120,7 +116,6 @@ virConnectDoStoreList(virConnectPtr conn, const char *path,
return xs_directory (priv->xshandle, 0, path, nb);
}
-#endif /* ! PROXY */
/**
* virDomainDoStoreQuery:
@@ -152,7 +147,6 @@ virDomainDoStoreQuery(virConnectPtr conn, int domid, const char *path)
return xs_read(priv->xshandle, 0, &s[0], &len);
}
-#ifndef PROXY
/**
* virDomainDoStoreWrite:
* @domain: a domain object
@@ -254,7 +248,6 @@ virDomainGetVMInfo(virDomainPtr domain, const char *vm, const char *name)
return (ret);
}
-#endif /* ! PROXY */
/************************************************************************
* *
@@ -278,14 +271,10 @@ xenStoreOpen(virConnectPtr conn,
{
xenUnifiedPrivatePtr priv = (xenUnifiedPrivatePtr) conn->privateData;
-#ifdef PROXY
- priv->xshandle = xs_daemon_open_readonly();
-#else
if (flags & VIR_CONNECT_RO)
priv->xshandle = xs_daemon_open_readonly();
else
priv->xshandle = xs_daemon_open();
-#endif /* ! PROXY */
if (priv->xshandle == NULL) {
/*
@@ -300,7 +289,6 @@ xenStoreOpen(virConnectPtr conn,
return (-1);
}
-#ifndef PROXY
/* Init activeDomainList */
if (VIR_ALLOC(priv->activeDomainList) < 0) {
virReportOOMError();
@@ -341,7 +329,6 @@ xenStoreOpen(virConnectPtr conn,
NULL)) < 0)
DEBUG0("Failed to add event handle, disabling events");
-#endif //PROXY
return 0;
}
@@ -365,7 +352,6 @@ xenStoreClose(virConnectPtr conn)
priv = (xenUnifiedPrivatePtr) conn->privateData;
-#ifndef PROXY
if (xenStoreRemoveWatch(conn, "@introduceDomain", "introduceDomain") < 0) {
DEBUG0("Warning, could not remove @introduceDomain watch");
/* not fatal */
@@ -380,21 +366,19 @@ xenStoreClose(virConnectPtr conn)
priv->xsWatchList = NULL;
xenUnifiedDomainInfoListFree(priv->activeDomainList);
priv->activeDomainList = NULL;
-#endif
+
if (priv->xshandle == NULL)
return(-1);
-#ifndef PROXY
if (priv->xsWatch != -1)
virEventRemoveHandle(priv->xsWatch);
-#endif
+
xs_daemon_close(priv->xshandle);
priv->xshandle = NULL;
return (0);
}
-#ifndef PROXY
/**
* xenStoreGetDomainInfo:
* @domain: pointer to the domain block
@@ -444,7 +428,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
info->memory = 0;
info->maxMem = 0;
}
-# if 0
+#if 0
/* doesn't seems to work */
tmp = virDomainDoStoreQuery(domain->conn, domain->id, "cpu_time");
if (tmp != NULL) {
@@ -453,7 +437,7 @@ xenStoreGetDomainInfo(virDomainPtr domain, virDomainInfoPtr info)
} else {
info->cpuTime = 0;
}
-# endif
+#endif
snprintf(request, 199, "/local/domain/%d/cpu", domain->id);
request[199] = 0;
tmp2 = virConnectDoStoreList(domain->conn, request, &nb_vcpus);
@@ -685,10 +669,10 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
if ((endptr == idlist[i]) || (*endptr != 0)) {
goto done;
}
-# if 0
+#if 0
if (virConnectCheckStoreID(conn, (int) id) < 0)
continue;
-# endif
+#endif
snprintf(prop, 199, "/local/domain/%s/name", idlist[i]);
prop[199] = 0;
tmp = xs_read(priv->xshandle, 0, prop, &len);
@@ -811,7 +795,6 @@ xenStoreDomainGetOSType(virDomainPtr domain) {
return (str);
}
-#endif /* ! PROXY */
/**
* xenStoreDomainGetVNCPort:
@@ -860,52 +843,6 @@ char * xenStoreDomainGetConsolePath(virConnectPtr conn, int domid) {
return virDomainDoStoreQuery(conn, domid, "console/tty");
}
-#ifdef PROXY
-/*
- * xenStoreDomainGetOSTypeID:
- * @conn: pointer to the connection.
- * @id: the domain id
- *
- * Get the type of domain operation system.
- *
- * The caller must hold the lock on the privateData
- * associated with the 'conn' parameter.
- *
- * Returns the new string or NULL in case of error, the string must be
- * freed by the caller.
- */
-char *
-xenStoreDomainGetOSTypeID(virConnectPtr conn, int id) {
- char *vm, *str = NULL;
- char query[200];
- unsigned int len;
- xenUnifiedPrivatePtr priv;
-
- if (id < 0)
- return(NULL);
-
- priv = (xenUnifiedPrivatePtr) conn->privateData;
- if (priv->xshandle == NULL)
- return (NULL);
-
- snprintf(query, 199, "/local/domain/%d/vm", id);
- query[199] = 0;
-
- vm = xs_read(priv->xshandle, 0, &query[0], &len);
-
- if (vm) {
- snprintf(query, 199, "%s/image/ostype", vm);
- str = xs_read(priv->xshandle, 0, &query[0], &len);
- VIR_FREE(vm);
- }
- if (str == NULL)
- str = strdup("linux");
- if (str == NULL)
- virReportOOMError();
-
- return (str);
-}
-#endif /* PROXY */
/*
* xenStoreDomainGetNetworkID:
@@ -1122,7 +1059,6 @@ char *xenStoreDomainGetName(virConnectPtr conn,
return xs_read(priv->xshandle, 0, prop, &len);
}
-#ifndef PROXY
/*
* The caller must hold the lock on the privateData
* associated with the 'conn' parameter.
@@ -1496,5 +1432,3 @@ retry:
}
return 0;
}
-
-#endif //PROXY
diff --git a/src/xen/xs_internal.h b/src/xen/xs_internal.h
index d7a110d..afbc15a 100644
--- a/src/xen/xs_internal.h
+++ b/src/xen/xs_internal.h
@@ -37,13 +37,10 @@ int xenStoreDomainShutdown (virDomainPtr domain);
int xenStoreDomainReboot (virDomainPtr domain,
unsigned int flags);
-/* those are entry point for the proxy */
int xenStoreDomainGetVNCPort(virConnectPtr conn,
int domid);
char * xenStoreDomainGetConsolePath(virConnectPtr conn,
int domid);
-char * xenStoreDomainGetOSTypeID(virConnectPtr conn,
- int id);
char * xenStoreDomainGetNetworkID(virConnectPtr conn,
int id,
const char *mac);
--
1.7.0.4
13 years, 12 months
[libvirt] [PATCH] lxc: Exit on first error in lxcDomainGetMemoryParameters
by Matthias Bolte
There is no point in trying to fill params beyond the first error,
because when lxcDomainGetMemoryParameters returns -1 then the caller
cannot detect which values in params are valid.
---
src/lxc/lxc_driver.c | 21 ++++++++-------------
1 files changed, 8 insertions(+), 13 deletions(-)
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index d39b60e..f7630dd 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -823,7 +823,6 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
goto cleanup;
}
- ret = 0;
for (i = 0; i < *nparams; i++) {
virMemoryParameterPtr param = ¶ms[i];
val = 0;
@@ -836,14 +835,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("unable to get memory hard limit"));
- ret = -1;
- continue;
+ goto cleanup;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_HARD_LIMIT) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field memory hard limit too long for destination"));
- ret = -1;
- continue;
+ goto cleanup;
}
param->value.ul = val;
break;
@@ -853,14 +850,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("unable to get memory soft limit"));
- ret = -1;
- continue;
+ goto cleanup;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SOFT_LIMIT) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field memory soft limit too long for destination"));
- ret = -1;
- continue;
+ goto cleanup;
}
param->value.ul = val;
break;
@@ -870,14 +865,12 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
if (rc != 0) {
virReportSystemError(-rc, "%s",
_("unable to get swap hard limit"));
- ret = -1;
- continue;
+ goto cleanup;
}
if (virStrcpyStatic(param->field, VIR_DOMAIN_MEMORY_SWAP_HARD_LIMIT) == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Field swap hard limit too long for destination"));
- ret = -1;
- continue;
+ goto cleanup;
}
param->value.ul = val;
break;
@@ -888,6 +881,8 @@ static int lxcDomainGetMemoryParameters(virDomainPtr dom,
}
}
+ ret = 0;
+
cleanup:
if (cgroup)
virCgroupFree(&cgroup);
--
1.7.0.4
13 years, 12 months
[libvirt] [PATCH] Allow virDomainGetMemoryParameters on read-only connections
by Matthias Bolte
Also fix a typo in the documentation of the function.
---
src/libvirt.c | 6 +-----
1 files changed, 1 insertions(+), 5 deletions(-)
diff --git a/src/libvirt.c b/src/libvirt.c
index aebd3bc..2ffb2d9 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -3096,7 +3096,7 @@ error:
* }
*
* This function requires privileged access to the hypervisor. This function
- * expects the caller to allocate the @param
+ * expects the caller to allocate the @params.
*
* Returns -1 in case of error, 0 in case of success.
*/
@@ -3115,10 +3115,6 @@ virDomainGetMemoryParameters(virDomainPtr domain,
virDispatchError(NULL);
return -1;
}
- if (domain->conn->flags & VIR_CONNECT_RO) {
- virLibDomainError(domain, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
- goto error;
- }
if ((nparams == NULL) || (*nparams < 0)) {
virLibDomainError(domain, VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
--
1.7.0.4
13 years, 12 months
[libvirt] New compile failure on OSX: CLOCK_REALTIME undeclared
by Justin Clift
Hi Eric,
When running 'make check' on OSX (git head) it's erroring out with:
eventtest.c: In function 'finishJob':
eventtest.c:216: warning: implicit declaration of function 'clock_gettime'
eventtest.c:216: warning: nested extern declaration of 'clock_gettime' [-Wnested-externs]
eventtest.c:216: error: 'CLOCK_REALTIME' undeclared (first use in this function)
eventtest.c:216: error: (Each undeclared identifier is reported only once
eventtest.c:216: error: for each function it appears in.)
make[3]: *** [eventtest.o] Error 1
make[2]: *** [check-am] Error 2
make[1]: *** [check-recursive] Error 1
make: *** [check-recursive] Error 1
$
Looks like the CLOCK_REALTIME is a glibc Linux thing. It's in /usr/include/time/bits.h on
a F13 box.
Any idea if gnulib can be used to get around this?
Regards and best wishes,
Justin Clift
13 years, 12 months
[libvirt] [PATCH] qemu: Add flag to force a CDROM eject
by Cole Robinson
QEMU allows forcing a CDROM eject even if the guest has locked the device.
Expose this via a new UpdateDevice flag, VIR_DOMAIN_DEVICE_EJECT_FORCE.
This has been requested for RHEV:
https://bugzilla.redhat.com/show_bug.cgi?id=626305
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
include/libvirt/libvirt.h.in | 1 +
src/qemu/qemu_driver.c | 14 +++++++++-----
src/qemu/qemu_monitor.c | 9 +++++----
src/qemu/qemu_monitor.h | 6 ++----
src/qemu/qemu_monitor_json.c | 5 +++--
src/qemu/qemu_monitor_json.h | 3 ++-
src/qemu/qemu_monitor_text.c | 5 +++--
src/qemu/qemu_monitor_text.h | 3 ++-
8 files changed, 27 insertions(+), 19 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 81db3a2..83cbb57 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -1033,6 +1033,7 @@ typedef enum {
VIR_DOMAIN_DEVICE_MODIFY_CURRENT = 0, /* Modify device allocation based on current domain state */
VIR_DOMAIN_DEVICE_MODIFY_LIVE = (1 << 0), /* Modify live device allocation */
VIR_DOMAIN_DEVICE_MODIFY_CONFIG = (1 << 1), /* Modify persisted device allocation */
+ VIR_DOMAIN_DEVICE_EJECT_FORCE = (1 << 2), /* Forcibly eject media */
} virDomainDeviceModifyFlags;
int virDomainAttachDevice(virDomainPtr domain, const char *xml);
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index e7b37e1..ecfb081 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -7686,7 +7686,8 @@ cleanup:
static int qemudDomainChangeEjectableMedia(struct qemud_driver *driver,
virDomainObjPtr vm,
virDomainDiskDefPtr disk,
- unsigned long long qemuCmdFlags)
+ unsigned long long qemuCmdFlags,
+ bool force)
{
virDomainDiskDefPtr origdisk = NULL;
int i;
@@ -7747,7 +7748,7 @@ static int qemudDomainChangeEjectableMedia(struct qemud_driver *driver,
driveAlias,
disk->src, format);
} else {
- ret = qemuMonitorEjectMedia(priv->mon, driveAlias);
+ ret = qemuMonitorEjectMedia(priv->mon, driveAlias, force);
}
qemuDomainObjExitMonitorWithDriver(driver, vm);
@@ -8719,7 +8720,8 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
ret = qemudDomainChangeEjectableMedia(driver, vm,
dev->data.disk,
- qemuCmdFlags);
+ qemuCmdFlags,
+ 0);
if (ret == 0)
dev->data.disk = NULL;
break;
@@ -8909,7 +8911,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
virCheckFlags(VIR_DOMAIN_DEVICE_MODIFY_CURRENT |
VIR_DOMAIN_DEVICE_MODIFY_LIVE |
- VIR_DOMAIN_DEVICE_MODIFY_CONFIG, -1);
+ VIR_DOMAIN_DEVICE_MODIFY_CONFIG |
+ VIR_DOMAIN_DEVICE_EJECT_FORCE, -1);
if (flags & VIR_DOMAIN_DEVICE_MODIFY_CONFIG) {
qemuReportError(VIR_ERR_OPERATION_INVALID,
@@ -8964,7 +8967,8 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr dom,
case VIR_DOMAIN_DISK_DEVICE_FLOPPY:
ret = qemudDomainChangeEjectableMedia(driver, vm,
dev->data.disk,
- qemuCmdFlags);
+ qemuCmdFlags,
+ flags & VIR_DOMAIN_DEVICE_EJECT_FORCE);
if (ret == 0)
dev->data.disk = NULL;
break;
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 2366fdb..3600fd8 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -1146,10 +1146,11 @@ int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, int online)
int qemuMonitorEjectMedia(qemuMonitorPtr mon,
- const char *devname)
+ const char *devname,
+ bool force)
{
int ret;
- DEBUG("mon=%p devname=%s", mon, devname);
+ DEBUG("mon=%p devname=%s force=%d", mon, devname, force);
if (!mon) {
qemuReportError(VIR_ERR_INVALID_ARG, "%s",
@@ -1158,9 +1159,9 @@ int qemuMonitorEjectMedia(qemuMonitorPtr mon,
}
if (mon->json)
- ret = qemuMonitorJSONEjectMedia(mon, devname);
+ ret = qemuMonitorJSONEjectMedia(mon, devname, force);
else
- ret = qemuMonitorTextEjectMedia(mon, devname);
+ ret = qemuMonitorTextEjectMedia(mon, devname, force);
return ret;
}
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 7d09145..41b3135 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -203,12 +203,10 @@ int qemuMonitorSetCPU(qemuMonitorPtr mon, int cpu, int online);
/* XXX should we pass the virDomainDiskDefPtr instead
* and hide devname details inside monitor. Reconsider
* this when doing the QMP implementation
- *
- * XXXX 'eject' has gained a 'force' flag we might like
- * to make use of...
*/
int qemuMonitorEjectMedia(qemuMonitorPtr mon,
- const char *devname);
+ const char *devname,
+ bool force);
int qemuMonitorChangeMedia(qemuMonitorPtr mon,
const char *devname,
const char *newmedia,
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index d2c6f0a..da51a4f 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -1348,12 +1348,13 @@ cleanup:
int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
- const char *devname)
+ const char *devname,
+ bool force)
{
int ret;
virJSONValuePtr cmd = qemuMonitorJSONMakeCommand("eject",
"s:device", devname,
- "b:force", 0,
+ "b:force", force ? 1 : 0,
NULL);
virJSONValuePtr reply = NULL;
if (!cmd)
diff --git a/src/qemu/qemu_monitor_json.h b/src/qemu/qemu_monitor_json.h
index 94806c1..c78ee24 100644
--- a/src/qemu/qemu_monitor_json.h
+++ b/src/qemu/qemu_monitor_json.h
@@ -68,7 +68,8 @@ int qemuMonitorJSONSetBalloon(qemuMonitorPtr mon,
int qemuMonitorJSONSetCPU(qemuMonitorPtr mon, int cpu, int online);
int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
- const char *devname);
+ const char *devname,
+ bool force);
int qemuMonitorJSONChangeMedia(qemuMonitorPtr mon,
const char *devname,
const char *newmedia,
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
index 7f15008..2552111 100644
--- a/src/qemu/qemu_monitor_text.c
+++ b/src/qemu/qemu_monitor_text.c
@@ -848,13 +848,14 @@ int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online)
int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
- const char *devname)
+ const char *devname,
+ bool force)
{
char *cmd = NULL;
char *reply = NULL;
int ret = -1;
- if (virAsprintf(&cmd, "eject %s", devname) < 0) {
+ if (virAsprintf(&cmd, "eject %s%s", force ? "-f " : "", devname) < 0) {
virReportOOMError();
goto cleanup;
}
diff --git a/src/qemu/qemu_monitor_text.h b/src/qemu/qemu_monitor_text.h
index c017509..983f402 100644
--- a/src/qemu/qemu_monitor_text.h
+++ b/src/qemu/qemu_monitor_text.h
@@ -66,7 +66,8 @@ int qemuMonitorTextSetBalloon(qemuMonitorPtr mon,
int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, int online);
int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
- const char *devname);
+ const char *devname,
+ bool force);
int qemuMonitorTextChangeMedia(qemuMonitorPtr mon,
const char *devname,
const char *newmedia,
--
1.7.2.1
13 years, 12 months