[libvirt] [PATCH] remove cvs $Id$ strings
by Jim Meyering
Here's the change to remove the few remaining CVS $Id$ strings:
>From f2a2d1403656cdfe6e927c476da66ad0c49487ae Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 12 Dec 2008 13:36:08 +0100
Subject: [PATCH] remove cvs $Id$ strings
* po/id.po: Likewise.
* qemud/remote_generate_stubs.pl: Likewise.
* src/virsh.c: Likewise.
* tests/testutils.c: Likewise.
* tests/testutils.h: Likewise.
* RENAMES: Likewise.
---
RENAMES | 2 --
po/id.po | 1 -
qemud/remote_generate_stubs.pl | 2 --
src/virsh.c | 3 ---
tests/testutils.c | 4 +---
tests/testutils.h | 4 +---
6 files changed, 2 insertions(+), 14 deletions(-)
diff --git a/RENAMES b/RENAMES
index 27f85a4..143aebd 100644
--- a/RENAMES
+++ b/RENAMES
@@ -2,8 +2,6 @@
#
# File renames don't normally go into patches because they make
# the patches much harder to read, so list them here instead.
-#
-# $Id$
# Clearer naming scheme after Xen-unified patch went in.
src/xen_internal.c src/xen_internal_hv.c
diff --git a/po/id.po b/po/id.po
index 5590e65..458b033 100644
--- a/po/id.po
+++ b/po/id.po
@@ -1,7 +1,6 @@
# translation of libvirt to Bahasa Indonesia (id).
# This file is distributed under the same license as the libvirt package.
# Teguh DC <dheche(a)songolimo.net>, 2007.
-# $Id$
msgid ""
msgstr ""
"Project-Id-Version: libvirt\n"
diff --git a/qemud/remote_generate_stubs.pl b/qemud/remote_generate_stubs.pl
index 2dff468..44e1552 100755
--- a/qemud/remote_generate_stubs.pl
+++ b/qemud/remote_generate_stubs.pl
@@ -4,8 +4,6 @@
# code for both ends of the remote connection.
#
# By Richard Jones <rjones(a)redhat.com>
-#
-# $Id$
use strict;
diff --git a/src/virsh.c b/src/virsh.c
index 1a5b42f..f4a57f4 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -8,9 +8,6 @@
* Daniel Veillard <veillard(a)redhat.com>
* Karel Zak <kzak(a)redhat.com>
* Daniel P. Berrange <berrange(a)redhat.com>
- *
- *
- * $Id$
*/
#include <config.h>
diff --git a/tests/testutils.c b/tests/testutils.c
index 0255bdf..187123c 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -1,13 +1,11 @@
/*
* testutils.c: basic test utils
*
- * Copyright (C) 2005-2007 Red Hat, Inc.
+ * Copyright (C) 2005-2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Karel Zak <kzak(a)redhat.com>
- *
- * $Id$
*/
#include <config.h>
diff --git a/tests/testutils.h b/tests/testutils.h
index 7afd579..fd326ae 100644
--- a/tests/testutils.h
+++ b/tests/testutils.h
@@ -1,13 +1,11 @@
/*
* utils.c: test utils
*
- * Copyright (C) 2005 Red Hat, Inc.
+ * Copyright (C) 2005, 2008 Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Karel Zak <kzak(a)redhat.com>
- *
- * $Id$
*/
#ifndef __VIT_TEST_UTILS_H__
--
1.6.0.4.1044.g77718
16 years
[libvirt] Re: [PATCH/RFC] kvm/qemu vs libvirtd restarts
by Daniel P. Berrange
Moving thread to libvir-list....
On Tue, Oct 07, 2008 at 06:12:33PM +0200, Guido G?nther wrote:
> On Fri, Sep 26, 2008 at 04:47:05PM +0100, Daniel P. Berrange wrote:
> > On Fri, Sep 26, 2008 at 05:41:02PM +0200, Guido G?nther wrote:
> >
> > We've got this problem sorted in the 'lxc' driver and need to apply
> > the same approach to the QEMU driver. The problem was always finding
> > the Pseduo-TTY/PID for the monitor after restart, and associating the
> > live config with it. We've "solved" that in LXC driver by savingt the
> > live XML & PID to /var/run/libvirt/lxc/. It basically needs the same
> > approach to be applied to the QEMU daemons. In addition the DNSmasq
> > deamon needs adapting for simiarl reasons.
>
> Attached is a very early patch. It keeps the qemu instances running and
> writes out their states upon shutdown. Reconnecting (and therefore sending
> monitor commands, etc.) works but since stdout/stderr don't get picked
> up again yet we don't handle virEventAddhandle. I'll grab them from
> /proc/<pid>/fd/{1,2} later. Network state is missing too, but since this
> is moving into a separate file it's becoming a different matter anyway.
First off, thanks for working on this! A few general comments, and then
I'll put rest inline..
For stdout/err, it need to be setup so that the logfile is dup()'d onto
the QEMU process' file descriptors directly, and get libvirt outof the
business of I/O forwarding. This avoids any complications with re-attaching
to stdout/err, and loosing any log data while libvirt isn't running.
This also needs to be implemented with the assumption that the daemon
can & will crash any time. So putting the state-saving hooks into the
qemudShutdown() method won't be sufficient. We need to write out the
state we need when initially starting the VM, and then update it any
time we hot-plug/unplug devices.
Ignoring network state is fine - we can address that separately..
> Subject: [PATCH] let qemu/kvm survive libvirtd restarts
>
> ---
> src/domain_conf.c | 1 +
> src/domain_conf.h | 1 +
> src/qemu_conf.h | 1 +
> src/qemu_driver.c | 264 +++++++++++++++++++++++++++++++++++++++++++++++++----
> src/util.c | 4 +-
> src/util.h | 1 +
> 6 files changed, 254 insertions(+), 18 deletions(-)
>
> diff --git a/src/domain_conf.c b/src/domain_conf.c
> index 6a35064..aa102f6 100644
> --- a/src/domain_conf.c
> +++ b/src/domain_conf.c
> @@ -420,6 +420,7 @@ void virDomainObjFree(virDomainObjPtr dom)
> virDomainDefFree(dom->def);
> virDomainDefFree(dom->newDef);
>
> + VIR_FREE(dom->monitorpath);
> VIR_FREE(dom->vcpupids);
>
> VIR_FREE(dom);
> diff --git a/src/domain_conf.h b/src/domain_conf.h
> index 632e5ad..1ac1561 100644
> --- a/src/domain_conf.h
> +++ b/src/domain_conf.h
> @@ -448,6 +448,7 @@ struct _virDomainObj {
> int stdout_fd;
> int stderr_fd;
> int monitor;
> + char *monitorpath;
I think we can avoid needing this. If we write out the staste the
moment the VM is started, we don't need to carry this around in
memory. Alternatively, since we're writing all stdout/err data to
the logfile, we could simply re-parse the log to extract the
monitor path upon restart.
> int logfile;
> int pid;
> int state;
> diff --git a/src/qemu_conf.h b/src/qemu_conf.h
> index 88dfade..f47582e 100644
> --- a/src/qemu_conf.h
> +++ b/src/qemu_conf.h
> @@ -62,6 +62,7 @@ struct qemud_driver {
> char *networkConfigDir;
> char *networkAutostartDir;
> char *logDir;
> + char *stateDir;
> unsigned int vncTLS : 1;
> unsigned int vncTLSx509verify : 1;
> char *vncTLSx509certdir;
> diff --git a/src/qemu_driver.c b/src/qemu_driver.c
> index 806608d..87789a9 100644
> --- a/src/qemu_driver.c
> +++ b/src/qemu_driver.c
> @@ -172,6 +172,181 @@ void qemudAutostartConfigs(struct qemud_driver *driver) {
> }
>
> #ifdef WITH_LIBVIRTD
> +
> +static int
> +qemudFileWriteMonitor(const char *dir,
> + const char *name,
> + const char *path)
> +{
> + int rc;
> + int fd;
> + FILE *file = NULL;
> + char *monitorfile = NULL;
> +
> + if ((rc = virFileMakePath(dir)))
> + goto cleanup;
> +
> + if (asprintf(&monitorfile, "%s/%s.monitor", dir, name) < 0) {
> + rc = ENOMEM;
> + goto cleanup;
> + }
> +
> + if ((fd = open(monitorfile,
> + O_WRONLY | O_CREAT | O_TRUNC,
> + S_IRUSR | S_IWUSR)) < 0) {
> + rc = errno;
> + goto cleanup;
> + }
> +
> + if (!(file = fdopen(fd, "w"))) {
> + rc = errno;
> + close(fd);
> + goto cleanup;
> + }
> +
> + if (fprintf(file, "%s", path) < 0) {
> + rc = errno;
> + goto cleanup;
> + }
> +
> + rc = 0;
> +
> +cleanup:
> + if (file &&
> + fclose(file) < 0) {
> + rc = errno;
> + }
> +
> + VIR_FREE(monitorfile);
> + return rc;
> +}
> +
> +static int
> +qemudFileReadMonitor(const char *dir,
> + const char *name,
> + char **path)
> +{
> + int rc;
> + FILE *file;
> + char *monitorfile = NULL;
> +
> + if (asprintf(&monitorfile, "%s/%s.monitor", dir, name) < 0) {
> + rc = ENOMEM;
> + goto cleanup;
> + }
> +
> + if (!(file = fopen(monitorfile, "r"))) {
> + rc = errno;
> + goto cleanup;
> + }
> +
> + if (fscanf(file, "%as", path) != 1) {
> + rc = EINVAL;
> + goto cleanup;
> + }
> +
> + if (fclose(file) < 0) {
> + rc = errno;
> + goto cleanup;
> + }
> +
> + rc = 0;
> +
> + cleanup:
> + VIR_FREE(monitorfile);
> + return rc;
> +}
If we re-parse the logfile to extract the monitiro PTY path, this is
unneccessary. If not, this can be simplied by just calling the
convenient virFileReadAll() method.
> +
> +static int
> +qemudFileDeleteMonitor(const char *dir,
> + const char *name)
> +{
> + int rc = 0;
> + char *pidfile = NULL;
> +
> + if (asprintf(&pidfile, "%s/%s.monitor", dir, name) < 0) {
> + rc = errno;
> + goto cleanup;
> + }
> +
> + if (unlink(pidfile) < 0 && errno != ENOENT)
> + rc = errno;
> +
> +cleanup:
> + VIR_FREE(pidfile);
> + return rc;
> +}
> +
> +
> +static int qemudOpenMonitor(virConnectPtr conn,
> + struct qemud_driver *driver,
> + virDomainObjPtr vm,
> + const char *monitor,
> + int reconnect);
> +/**
> + * qemudReconnectVMs
> + *
> + * Reconnect running vms to the daemon process
> + */
> +static int
> +qemudReconnectVMs(struct qemud_driver *driver)
> +{
> + virDomainObjPtr vm = driver->domains;
> +
> + while (vm) {
> + virDomainDefPtr tmp;
> + char *config = NULL;
> + char *monitor = NULL;
> + int rc;
> +
> + /* Read pid */
> + if ((rc = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) == 0) {
> + virFileDeletePid(driver->stateDir, vm->def->name);
> + DEBUG("Found pid %d for '%s'", vm->pid, vm->def->name);
> + } else
> + goto next;
> +
> + if ((config = virDomainConfigFile(NULL,
> + driver->stateDir,
> + vm->def->name)) == NULL) {
> + qemudLog(QEMUD_ERR, _("Failed to read back domain config for %s\n"),
> + vm->def->name);
> + goto next;
> + }
> +
> + /* Try and load the config */
> + tmp = virDomainDefParseFile(NULL, driver->caps, config);
> + unlink(config);
> + if (tmp) {
> + vm->newDef = vm->def;
> + vm->def = tmp;
> + }
> +
> + /* read back monitor path */
> + if ((rc = qemudFileReadMonitor(driver->stateDir, vm->def->name, &monitor)) != 0) {
> + qemudLog(QEMUD_ERR, _("Failed to read back monitor path for %s: %s\n"),
> + vm->def->name, strerror(rc));
> + goto next;
> + }
> + qemudFileDeleteMonitor(driver->stateDir, vm->def->name);
> +
> + /* FIXME: reconnect stdout/stderr via /proc/pid/fd/ */
> +
> + if ((rc = qemudOpenMonitor(NULL, driver, vm, monitor, 1)) != 0) {
> + qemudLog(QEMUD_ERR, _("Failed to reconnect to monitor for %s: %d\n"),
> + vm->def->name, rc);
> + goto next;
> + }
> + vm->def->id = driver->nextvmid++;
The ID of a vm must never change for until it is rebooted. Simply
don't overwrite the existing vm->def->id that we jjust loaded off
disk. And instead adjust the nextvmid field, eg
if (vm->def->id >= driver->nextvmid)
driver->nextvmid = vm->def->id + 1;
> + vm->state = VIR_DOMAIN_RUNNING;
> +next:
> + VIR_FREE(config);
> + VIR_FREE(monitor);
> + vm = vm->next;
> + }
> + return 0;
> +}
> +
> /**
> * qemudStartup:
> *
> @@ -197,6 +372,10 @@ qemudStartup(void) {
>
> if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
> goto out_of_memory;
> +
> + if (asprintf (&qemu_driver->stateDir,
> + "%s/run/libvirt/qemu/", LOCAL_STATE_DIR) == -1)
> + goto out_of_memory;
> } else {
> if (!(pw = getpwuid(uid))) {
> qemudLog(QEMUD_ERR, _("Failed to find user record for uid '%d': %s\n"),
> @@ -210,6 +389,10 @@ qemudStartup(void) {
>
> if (asprintf (&base, "%s/.libvirt", pw->pw_dir) == -1)
> goto out_of_memory;
> +
> + if (asprintf (&qemu_driver->stateDir,
> + "%s/run/libvirt/qemu/", base) == -1)
> + goto out_of_memory;
> }
>
> /* Configuration paths are either ~/.libvirt/qemu/... (session) or
> @@ -250,6 +433,8 @@ qemudStartup(void) {
> qemudShutdown();
> return -1;
> }
> + qemudReconnectVMs(qemu_driver);
> +
> if (virNetworkLoadAllConfigs(NULL,
> &qemu_driver->networks,
> qemu_driver->networkConfigDir,
> @@ -329,6 +514,34 @@ qemudActive(void) {
> return 0;
> }
>
> +/**
> + * qemudSaveDomainState
> + *
> + * Save the full state of a running domain to statedir
> + *
> + * Returns 0 on success
> + */
> +static int
> +qemudSaveDomainState(struct qemud_driver * driver, virDomainObjPtr vm) {
> + int ret;
> +
> + if ((ret = virFileWritePid(driver->stateDir, vm->def->name, vm->pid)) != 0) {
> + qemudLog(QEMUD_ERR, _("Unable to safe pidfile for %s: %s\n"),
> + vm->def->name, strerror(ret));
> + return ret;
> + }
> + if ((ret = virDomainSaveConfig(NULL, driver->stateDir, vm->def))) {
> + qemudLog(QEMUD_ERR, _("Unable to save domain %s\n"), vm->def->name);
> + return ret;
> + }
> + if ((ret = qemudFileWriteMonitor(driver->stateDir, vm->def->name, vm->monitorpath)) != 0) {
> + qemudLog(QEMUD_ERR, _("Unable to monitor file for %s: %s\n"),
> + vm->def->name, strerror(ret));
> + return ret;
> + }
> + return 0;
> +}
> +
This will need to be called at time of VM creation, and the
XSL config will need updating whether live config changes.
> /**
> * qemudShutdown:
> *
> @@ -349,10 +562,14 @@ qemudShutdown(void) {
> while (vm) {
> virDomainObjPtr next = vm->next;
> if (virDomainIsActive(vm))
> +#if 1
> + qemudSaveDomainState(qemu_driver, vm);
> +#else
> qemudShutdownVMDaemon(NULL, qemu_driver, vm);
> if (!vm->persistent)
> virDomainRemoveInactive(&qemu_driver->domains,
> vm);
> +#endif
> vm = next;
> }
>
> @@ -389,6 +606,7 @@ qemudShutdown(void) {
> VIR_FREE(qemu_driver->networkConfigDir);
> VIR_FREE(qemu_driver->networkAutostartDir);
> VIR_FREE(qemu_driver->vncTLSx509certdir);
> + VIR_FREE(qemu_driver->stateDir);
>
> if (qemu_driver->brctl)
> brShutdown(qemu_driver->brctl);
> @@ -499,7 +717,7 @@ qemudCheckMonitorPrompt(virConnectPtr conn ATTRIBUTE_UNUSED,
> static int qemudOpenMonitor(virConnectPtr conn,
> struct qemud_driver *driver,
> virDomainObjPtr vm,
> - const char *monitor) {
> + const char *monitor, int reconnect) {
> int monfd;
> char buf[1024];
> int ret = -1;
> @@ -520,11 +738,26 @@ static int qemudOpenMonitor(virConnectPtr conn,
> goto error;
> }
>
> - ret = qemudReadMonitorOutput(conn,
> - driver, vm, monfd,
> - buf, sizeof(buf),
> - qemudCheckMonitorPrompt,
> - "monitor");
> + if (!reconnect) {
> + ret = qemudReadMonitorOutput(conn,
> + driver, vm, monfd,
> + buf, sizeof(buf),
> + qemudCheckMonitorPrompt,
> + "monitor");
> +
> + } else {
> + vm->monitor = monfd;
> + ret = 0;
> + }
> +
> + if (ret != 0)
> + goto error;
> +
> + if (!(vm->monitorpath = strdup(monitor))) {
> + qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
> + "%s", _("failed to allocate space for monitor path"));
> + goto error;
> + }
>
> /* Keep monitor open upon success */
> if (ret == 0)
> @@ -623,7 +856,7 @@ qemudFindCharDevicePTYs(virConnectPtr conn,
> }
>
> /* Got them all, so now open the monitor console */
> - ret = qemudOpenMonitor(conn, driver, vm, monitor);
> + ret = qemudOpenMonitor(conn, driver, vm, monitor, 0);
>
> cleanup:
> VIR_FREE(monitor);
> @@ -966,12 +1199,11 @@ static int qemudStartVMDaemon(virConnectPtr conn,
>
> ret = virExec(conn, argv, NULL, &keepfd, &vm->pid,
> vm->stdin_fd, &vm->stdout_fd, &vm->stderr_fd,
> - VIR_EXEC_NONBLOCK);
> + VIR_EXEC_NONBLOCK | VIR_EXEC_SETSID);
> if (ret == 0) {
> vm->def->id = driver->nextvmid++;
> vm->state = migrateFrom ? VIR_DOMAIN_PAUSED : VIR_DOMAIN_RUNNING;
> }
> -
> for (i = 0 ; argv[i] ; i++)
> VIR_FREE(argv[i]);
> VIR_FREE(argv);
> @@ -1037,7 +1269,9 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
>
> qemudLog(QEMUD_INFO, _("Shutting down VM '%s'\n"), vm->def->name);
>
> - kill(vm->pid, SIGTERM);
> + if (kill(vm->pid, SIGTERM) < 0)
> + qemudLog(QEMUD_ERROR, _("Failed to send SIGTERM to %s (%d): %s\n"),
> + vm->def->name, vm->pid, strerror(errno));
>
> qemudVMData(driver, vm, vm->stdout_fd);
> qemudVMData(driver, vm, vm->stderr_fd);
> @@ -1057,13 +1291,9 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
> vm->stderr_fd = -1;
> vm->monitor = -1;
>
> - if (waitpid(vm->pid, NULL, WNOHANG) != vm->pid) {
> - kill(vm->pid, SIGKILL);
> - if (waitpid(vm->pid, NULL, 0) != vm->pid) {
> - qemudLog(QEMUD_WARN,
> - "%s", _("Got unexpected pid, damn\n"));
> - }
> - }
> + /* shut if off for sure */
> + kill(vm->pid, SIGKILL);
> + virFileDeletePid(driver->stateDir, vm->def->name);
>
> vm->pid = -1;
> vm->def->id = -1;
> diff --git a/src/util.c b/src/util.c
> index ca14be1..442c810 100644
> --- a/src/util.c
> +++ b/src/util.c
> @@ -299,14 +299,16 @@ virExec(virConnectPtr conn,
> !FD_ISSET(i, keepfd)))
> close(i);
>
> - if (flags & VIR_EXEC_DAEMON) {
> + if (flags & VIR_EXEC_DAEMON || flags & VIR_EXEC_SETSID) {
> if (setsid() < 0) {
> ReportError(conn, VIR_ERR_INTERNAL_ERROR,
> _("cannot become session leader: %s"),
> strerror(errno));
> _exit(1);
> }
> + }
>
> + if (flags & VIR_EXEC_DAEMON) {
> if (chdir("/") < 0) {
> ReportError(conn, VIR_ERR_INTERNAL_ERROR,
> _("cannot change to root directory: %s"),
> diff --git a/src/util.h b/src/util.h
> index 093ef46..8fbe2cd 100644
> --- a/src/util.h
> +++ b/src/util.h
> @@ -32,6 +32,7 @@ enum {
> VIR_EXEC_NONE = 0,
> VIR_EXEC_NONBLOCK = (1 << 0),
> VIR_EXEC_DAEMON = (1 << 1),
> + VIR_EXEC_SETSID = (1 << 2),
> };
Shouldn't we simply be starting all the QEMU VMs with VIR_EXEC_DAEMON
so they totally disassociate themselves from libvirtd right away. They
will be disassociated anyway if the libvirtd is ever restarted, so best
to daemonize from time they are started, to avoid any surprising changes
in behaviour
Regards,
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
16 years
[libvirt] [PATCH] fix size parameter in calls to numa_node_to_cpus
by Dave Allan
I was getting the error:
map size mismatch; abort
when running the daemon-conf tests.
I traced it to two places in which we were passing a parameter as a
number of bits to numa_node_to_cpus which expects a number of bytes (see
numa_node_to_cpus_compat in numa.h in the numactl source).
The attached patch fixes the problem.
Dave
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index e6c378f..7019c14 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -324,7 +324,7 @@ qemudCapsInitNUMA(virCapsPtr caps)
for (n = 0 ; n <= numa_max_node() ; n++) {
- if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN) < 0)
+ if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN / 8) < 0)
goto cleanup;
for (ncpus = 0, i = 0 ; i < MAX_CPUS ; i++)
diff --git a/src/uml_conf.c b/src/uml_conf.c
index 7eb630d..3659c6b 100644
--- a/src/uml_conf.c
+++ b/src/uml_conf.c
@@ -80,7 +80,7 @@ umlCapsInitNUMA(virCapsPtr caps)
for (n = 0 ; n <= numa_max_node() ; n++) {
- if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN) < 0)
+ if (numa_node_to_cpus(n, mask, MAX_CPUS_MASK_LEN / 8) < 0)
goto cleanup;
for (ncpus = 0, i = 0 ; i < MAX_CPUS ; i++)
16 years
[libvirt] [PATCH] avoid a spurious test failure on non-numa systems
by Jim Meyering
Daniel Veillard spotted this failure, due to a harmless diagnostic:
--- expected-err 2008-12-12 16:10:18.000000000 +0100 [16:21]
+++ err 2008-12-12 16:10:18.000000000 +0100
@@ -1,2 +1,3 @@
+libnuma: Warning: /sys not mounted or no numa system. Assuming one node:
No such file or directory
Here's a patch that should make the test ignore that diagnostic.
Daniel, if you could test, I'd appreciate it.
>From d336426d0127313b014ee453062b342b82ffcf6a Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 12 Dec 2008 16:38:58 +0100
Subject: [PATCH] avoid a spurious test failure on non-numa systems
* tests/daemon-conf: Ignore a spurious libnuma warning.
Reported by Daniel Veillard.
---
tests/daemon-conf | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/tests/daemon-conf b/tests/daemon-conf
index 03189d5..65a9655 100755
--- a/tests/daemon-conf
+++ b/tests/daemon-conf
@@ -56,8 +56,11 @@ while :; do
test $i = $n && break
- # Filter out this diagnostic.
- sed '/^Cannot set group when not running as root$/d' err > k && mv k err
+ # Filter out some ignorable diagnostics.
+ sed \
+ -e '/^Cannot set group when not running as root$/d' \
+ -e '/^libnuma: Warning: .sys not mounted or no numa system/d' \
+ err > k && mv k err
printf '%s\n\n' "remoteReadConfigFile: $f: $param_name: $msg" > expected-err
diff -u expected-err err || fail=1
--
1.6.0.4.1044.g77718
16 years
[libvirt] [PATCH] clarify Makefile message about tabbed indentation
by Dave Allan
I made a few changes to some of the sources, not realizing my editor was
using tabs for indentation which caused the build to complain. I wasn't
sure what the error was trying to tell me at first; here's a patch that
makes the message clearer (to me at least).
Dave
diff --git a/Makefile.maint b/Makefile.maint
index 10d481b..3b7594d 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -310,7 +310,7 @@ sc_TAB_in_indentation:
$$($(VC_LIST_EXCEPT) \
| grep -E '\.[ch](\.in)?$$' \
| grep -v '^gnulib/') && \
- { echo '$(ME): found TAB(s) use for indentation; use spaces' \
+ { echo '$(ME): found TAB(s) used for indentation in C sources; use spaces' \
1>&2; exit 1; } || :
ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
16 years
[libvirt] FYI, recent cvs history edit
by Jim Meyering
FYI, today, I committed this change
libvirtd: plug a nominal leak
* qemud/qemud.c (qemudRunLoop): Free server->workers.
http://git.et.redhat.com/?p=libvirt.git;a=commitdiff;h=87a6fa131464
Notice that it does have a proper ChangeLog entry, but the git commit
log contains only "*** empty log message ***". Normally it would contain
a copy of the ChangeLog lines.
However, in CVS, it is fixed because I manually edited the cvs commit log.
I expect that some day we'll regenerate the git repository from cvs,
so the empty summary in git will eventually go away
16 years
[libvirt] [PATCH] remove unused xmlrpc-related files
by Jim Meyering
While we once thought we'd use this xmlrpc code, it looks like
that's no longer in the cards, so this patch removes it,
along with the testing-related bits:
>From 18b7dbc92ad9d9f026bdc01ec735e389caffdfc1 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Fri, 12 Dec 2008 11:29:09 +0100
Subject: [PATCH] remove unused xmlrpc-related files
* src/xmlrpc.h: Remove file.
* src/xmlrpc.c: Likewise.
* tests/test_xmlrpc.sh: Likewise.
* tests/xmlrpctest.c: Likewise.
* tests/xmlrpcserver.py: Remove file.
* tests/Makefile.am (EXTRA_DIST): Remove xmlserver.py.
(noinst_PROGRAMS): Remove xmlrpctest, along with associated variables.
* po/POTFILES.in: Remove src/xmlrpc.c.
* tests/.cvsignore: Remove xmlrpctest.
---
po/POTFILES.in | 1 -
src/xmlrpc.c | 688 -------------------------------------------------
src/xmlrpc.h | 115 --------
tests/.cvsignore | 1 -
tests/Makefile.am | 12 +-
tests/test_xmlrpc.sh | 6 -
tests/xmlrpcserver.py | 49 ----
tests/xmlrpctest.c | 269 -------------------
8 files changed, 1 insertions(+), 1140 deletions(-)
delete mode 100644 src/xmlrpc.c
delete mode 100644 src/xmlrpc.h
delete mode 100755 tests/test_xmlrpc.sh
delete mode 100755 tests/xmlrpcserver.py
delete mode 100644 tests/xmlrpctest.c
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d33d24b..26617a0 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -40,5 +40,4 @@ src/xen_internal.c
src/xend_internal.c
src/xm_internal.c
src/xml.c
-src/xmlrpc.c
src/xs_internal.c
diff --git a/src/xmlrpc.c b/src/xmlrpc.c
deleted file mode 100644
index c90d694..0000000
--- a/src/xmlrpc.c
+++ /dev/null
@@ -1,688 +0,0 @@
-/*
- * xmlrpc.c: XML-RPC protocol handler for libvir library
- *
- * Copyright (C) 2006 IBM, Corp.
- *
- * See COPYING.LIB for the License of this software
- *
- * Anthony Liguori <aliguori(a)us.ibm.com>
- */
-
-#include <config.h>
-
-#include "xmlrpc.h"
-#include "virterror_internal.h"
-#include "memory.h"
-
-#include <libxml/nanohttp.h>
-
-#include <string.h>
-#include <errno.h>
-
-/* TODO
- 1) Lots of error checking
- 2) xmlRpcValueToSexpr
-*/
-
-static xmlNodePtr xmlFirstElement(xmlNodePtr node);
-static xmlNodePtr xmlNextElement(xmlNodePtr node);
-
-struct _xmlRpcContext
-{
- char *uri;
- int faultCode;
- char *faultMessage;
-};
-
-static void xmlRpcError(virErrorNumber error, const char *info, int value)
-{
- const char *errmsg;
-
- if (error == VIR_ERR_OK)
- return;
-
- errmsg = virErrorMsg(error, info);
- virRaiseError(NULL, NULL, NULL, VIR_FROM_RPC, error, VIR_ERR_ERROR,
- errmsg, info, NULL, value, 0, errmsg, info, value);
-}
-
-static xmlRpcValuePtr xmlRpcValueNew(xmlRpcValueType type)
-{
- xmlRpcValuePtr ret = NULL;
- if (VIR_ALLOC(ret) < 0)
- xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value"), sizeof(*ret));
- else
- ret->kind = type;
- return ret;
-}
-
-static char *xmlGetText(xmlNodePtr node)
-{
- for (node = node->children; node; node = node->next)
- if (node->type == XML_TEXT_NODE) {
- char *x = strdup((const char *)node->content);
- if (!x)
- xmlRpcError(VIR_ERR_NO_MEMORY, _("copying node content"),
- strlen((const char *)node->content));
- return x;
- }
- return NULL;
-}
-
-static xmlNodePtr xmlFirstElement(xmlNodePtr node)
-{
- for (node = node->children; node; node = node->next)
- if (node->type == XML_ELEMENT_NODE)
- break;
- return node;
-}
-
-static xmlNodePtr xmlNextElement(xmlNodePtr node)
-{
- for (node = node->next; node; node = node->next)
- if (node->type == XML_ELEMENT_NODE)
- break;
- return node;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalDateTime(xmlNodePtr node ATTRIBUTE_UNUSED)
-{
- /* we don't need this */
- TODO
- return NULL;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalString(xmlNodePtr node)
-{
- xmlRpcValuePtr ret = xmlRpcValueNew(XML_RPC_STRING);
-
- if (ret)
- ret->value.string = xmlGetText(node);
- return ret;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalBase64(xmlNodePtr node ATTRIBUTE_UNUSED)
-{
- /* we don't need this */
- TODO
- return NULL;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalInteger(xmlNodePtr node)
-{
- xmlRpcValuePtr ret = xmlRpcValueNew(XML_RPC_INTEGER);
- char *value = xmlGetText(node);
-
- if (ret && value)
- ret->value.integer = atoi(value);
- VIR_FREE(value);
- return ret;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalBoolean(xmlNodePtr node)
-{
- xmlRpcValuePtr ret = xmlRpcValueNew(XML_RPC_BOOLEAN);
- char *value = xmlGetText(node);
-
- if (!ret)
- return NULL;
- if (value && atoi(value))
- ret->value.boolean = true;
- else
- ret->value.boolean = false;
- VIR_FREE(value);
- return ret;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalDouble(xmlNodePtr node)
-{
- xmlRpcValuePtr ret = xmlRpcValueNew(XML_RPC_DOUBLE);
- char *value = xmlGetText(node);
-
- if (ret && value)
- ret->value.real = atof(value);
- VIR_FREE(value);
- return ret;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalArray(xmlNodePtr node)
-{
- xmlRpcValuePtr ret = xmlRpcValueNew(XML_RPC_ARRAY);
- xmlNodePtr cur;
- int n_elements = 0;
- xmlRpcValuePtr *elems;
-
- if (!ret)
- return NULL;
-
- for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur))
- n_elements += 1;
-
- if (VIR_ALLOC_N(elems, n_elements) < 0) {
- xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value array"),
- n_elements * sizeof(*elems));
- VIR_FREE(ret);
- return NULL;
- }
- n_elements = 0;
- for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur)) {
- elems[n_elements] = xmlRpcValueUnmarshal(cur);
- n_elements += 1;
- }
-
- ret->value.array.elements = elems;
- ret->value.array.n_elements = n_elements;
-
- return ret;
-}
-
-static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node)
-{
- xmlRpcValueDictElementPtr ret;
- xmlNodePtr cur;
-
- if (VIR_ALLOC(ret) < 0) {
- xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate dict"), sizeof(*ret));
- return NULL;
- }
- memset(ret, 0, sizeof(*ret));
-
- for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur)) {
- if (xmlStrEqual(cur->name, BAD_CAST "name")) {
- ret->name = xmlGetText(cur);
- } else if (xmlStrEqual(cur->name, BAD_CAST "value")) {
- ret->value = xmlRpcValueUnmarshal(cur);
- } else {
- xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected dict node"), 0);
- VIR_FREE(ret->name);
- if (ret->value)
- xmlRpcValueFree(ret->value);
- VIR_FREE(ret);
- return NULL;
- }
- }
-
- ret->next = NULL;
-
- return ret;
-}
-
-static xmlRpcValuePtr xmlRpcValueUnmarshalDict(xmlNodePtr node)
-{
- xmlRpcValueDictElementPtr root = NULL, *elem = &root;
- xmlRpcValuePtr ret = xmlRpcValueNew(XML_RPC_STRUCT);
- xmlNodePtr cur;
-
- if (!ret)
- return NULL;
-
- ret->value.dict.root = root;
-
- for (cur = xmlFirstElement(node); cur; cur = xmlNextElement(cur)) {
- *elem = xmlRpcValueUnmarshalDictElement(cur);
- if (*elem==NULL) {
- xmlRpcValueFree(ret);
- return NULL;
- }
- elem = &(*elem)->next;
- }
-
- return ret;
-}
-
-xmlRpcValuePtr xmlRpcValueUnmarshal(xmlNodePtr node)
-{
- xmlNodePtr n;
- xmlRpcValuePtr ret = NULL;
-
- if (xmlStrEqual(node->name, BAD_CAST "value")) {
- n = xmlFirstElement(node);
- if (n == NULL) {
- ret = xmlRpcValueUnmarshalString(node);
- } else {
- ret = xmlRpcValueUnmarshal(n);
- }
- } else if (xmlStrEqual(node->name, BAD_CAST "dateTime.iso8601")) {
- ret = xmlRpcValueUnmarshalDateTime(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "string")) {
- ret = xmlRpcValueUnmarshalString(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "base64")) {
- ret = xmlRpcValueUnmarshalBase64(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "i4") ||
- xmlStrEqual(node->name, BAD_CAST "int")) {
- ret = xmlRpcValueUnmarshalInteger(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "boolean")) {
- ret = xmlRpcValueUnmarshalBoolean(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "double")) {
- ret = xmlRpcValueUnmarshalDouble(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "array")) {
- ret = xmlRpcValueUnmarshal(xmlFirstElement(node));
- } else if (xmlStrEqual(node->name, BAD_CAST "data")) {
- ret = xmlRpcValueUnmarshalArray(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "struct")) {
- ret = xmlRpcValueUnmarshalDict(node);
- } else if (xmlStrEqual(node->name, BAD_CAST "nil")) {
- ret = xmlRpcValueNew(XML_RPC_NIL);
- } else {
- xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected value node"), 0);
- }
-
- return ret;
-}
-
-void xmlRpcValueFree(xmlRpcValuePtr value)
-{
- int i;
- xmlRpcValueDictElementPtr cur, next;
-
- if (value == NULL)
- return;
-
- switch (value->kind) {
- case XML_RPC_ARRAY:
- for (i = 0; i < value->value.array.n_elements; i++)
- xmlRpcValueFree(value->value.array.elements[i]);
- VIR_FREE(value->value.array.elements);
- break;
- case XML_RPC_STRUCT:
- next = value->value.dict.root;
- while (next) {
- cur = next;
- next = next->next;
- VIR_FREE(cur->name);
- xmlRpcValueFree(cur->value);
- VIR_FREE(cur);
- }
- break;
- case XML_RPC_STRING:
- VIR_FREE(value->value.string);
- break;
- default:
- break;
- }
-
- VIR_FREE(value);
-}
-
-void xmlRpcValueMarshal(xmlRpcValuePtr value, virBufferPtr buf, int indent)
-{
- int i;
- xmlRpcValueDictElement *elem;
-
- virBufferVSprintf(buf, "%*s<value>", indent, "");
- switch (value->kind) {
- case XML_RPC_ARRAY:
- virBufferStrcat(buf, "<array><data>\n", NULL);
- for (i = 0; i < value->value.array.n_elements; i++)
- xmlRpcValueMarshal(value->value.array.elements[i], buf, indent+2);
- virBufferVSprintf(buf, "%*s</data></array>", indent, "");
- break;
- case XML_RPC_STRUCT:
- virBufferStrcat(buf, "<struct>\n", NULL);
- indent += 2;
- for (elem = value->value.dict.root; elem; elem = elem->next) {
- virBufferVSprintf(buf, "%*s<member>\n", indent, "");
- virBufferVSprintf(buf, "%*s<name>%s</name>\n",
- indent + 2, "", elem->name);
- xmlRpcValueMarshal(elem->value, buf, indent + 2);
- virBufferVSprintf(buf, "%*s</member>\n", indent, "");
- }
- indent -= 2;
- virBufferVSprintf(buf, "%*s</struct>", indent, "");
- break;
- case XML_RPC_INTEGER:
- virBufferVSprintf(buf, "<int>%d</int>", value->value.integer);
- break;
- case XML_RPC_DOUBLE:
- virBufferVSprintf(buf, "<double>%f</double>", value->value.real);
- break;
- case XML_RPC_BOOLEAN:
- if (value->value.boolean)
- i = 1;
- else
- i = 0;
- virBufferVSprintf(buf, "<boolean>%d</boolean>", i);
- break;
- case XML_RPC_DATE_TIME:
- /* FIXME */
- TODO
- break;
- case XML_RPC_BASE64:
- /* FIXME */
- TODO
- break;
- case XML_RPC_STRING:
- virBufferStrcat(buf,
- "<string>", value->value.string, "</string>", NULL);
- break;
- case XML_RPC_NIL:
- virBufferStrcat(buf, "<nil> </nil>", NULL);
- break;
- }
- virBufferStrcat(buf, "</value>\n", NULL);
-}
-
-void xmlRpcMarshalRequest(const char *request,
- virBufferPtr buf,
- int argc, xmlRpcValuePtr *argv)
-{
- int i;
-
- virBufferStrcat(buf,
- "<?xml version=\"1.0\"?>\n"
- "<methodCall>\n"
- " <methodName>", request, "</methodName>\n"
- " <params>\n", NULL);
- for (i = 0; i < argc; i++) {
- virBufferStrcat(buf,
- " <param>\n", NULL);
- xmlRpcValueMarshal(argv[i], buf, 6);
- virBufferStrcat(buf,
- " </param>\n", NULL);
- }
- virBufferStrcat(buf,
- " </params>\n"
- "</methodCall>\n", NULL);
-}
-
-xmlRpcValuePtr xmlRpcUnmarshalResponse(xmlNodePtr node, bool *is_fault)
-{
- if (!node)
- return NULL;
-
- if (!xmlStrEqual(node->name, BAD_CAST "methodResponse"))
- return NULL;
-
- node = xmlFirstElement(node);
- if (xmlStrEqual(node->name, BAD_CAST "params")) {
- node = xmlFirstElement(node);
-
- if (!xmlStrEqual(node->name, BAD_CAST "param"))
- return NULL;
-
- *is_fault = false;
- return xmlRpcValueUnmarshal(xmlFirstElement(node));
- } else if (xmlStrEqual(node->name, BAD_CAST "fault")) {
- *is_fault = true;
- return xmlRpcValueUnmarshal(xmlFirstElement(node));
- } else
- return NULL;
-}
-
-static char *xmlRpcCallRaw(const char *url, const char *request)
-{
- void *cxt;
- char *contentType = (char *) "text/xml";
- int len, ret, serrno;
- char *response = NULL;
-
- cxt = xmlNanoHTTPMethod(url,
- "POST",
- request,
- &contentType,
- NULL,
- strlen(request));
-
- if (cxt == NULL) {
- xmlRpcError(VIR_ERR_POST_FAILED, _("send request"), 0);
- goto error;
- }
-
- if (contentType && STRNEQ(contentType, "text/xml")) {
- errno = EINVAL;
- xmlRpcError(VIR_ERR_POST_FAILED, _("unexpected mime type"), 0);
- goto error;
- }
-
- len = xmlNanoHTTPContentLength(cxt);
- if (VIR_ALLOC_N(response, len + 1) < 0) {
- xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate response"), len);
- goto error;
- }
- ret = xmlNanoHTTPRead(cxt, response, len);
- if (ret != len) {
- errno = EINVAL;
- VIR_FREE(response);
- xmlRpcError(VIR_ERR_POST_FAILED, _("read response"), 0);
- }
-
- response[len] = 0;
-
- error:
- serrno = errno;
- if (cxt) {
- xmlNanoHTTPClose(cxt);
- VIR_FREE(contentType);
- }
- errno = serrno;
-
- return response;
-}
-
-static char **xmlRpcStringArray(xmlRpcValuePtr value)
-{
- char **ret, *ptr;
- int i;
- size_t size = 0;
-
- if (value->kind != XML_RPC_ARRAY)
- return NULL;
-
- size = sizeof(char *) * (value->value.array.n_elements + 1);
-
- for (i = 0; i < value->value.array.n_elements; i++)
- if (value->value.array.elements[i]->kind == XML_RPC_STRING)
- size += strlen(value->value.array.elements[i]->value.string) + 1;
-
- if (VIR_ALLOC_N(ptr, size) < 0) {
- xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate string array"), size);
- return NULL;
- }
- ret = (char **)ptr;
- ptr += sizeof(char *) * (value->value.array.n_elements + 1);
-
- for (i = 0; i < value->value.array.n_elements; i++) {
- if (value->value.array.elements[i]->kind == XML_RPC_STRING) {
- char *s = value->value.array.elements[i]->value.string;
- strcpy(ptr, s);
- ret[i] = ptr;
- ptr += strlen(s) + 1;
- } else
- ret[i] = (char *) "";
- }
-
- ret[i] = NULL;
-
- return ret;
-}
-
-xmlRpcValuePtr *
-xmlRpcArgvNew(const char *fmt, va_list ap, int *argc)
-{
- xmlRpcValuePtr *argv;
- const char *ptr;
- int i;
-
- *argc = strlen(fmt);
- if (VIR_ALLOC_N(argv, *argc) < 0) {
- xmlRpcError(VIR_ERR_NO_MEMORY, _("read response"), sizeof(*argv) * *argc);
- return NULL;
- }
- i = 0;
- for (ptr = fmt; *ptr; ptr++) {
- switch (*ptr) {
- case 'i':
- if ((argv[i] = xmlRpcValueNew(XML_RPC_INTEGER)))
- argv[i]->value.integer = va_arg(ap, int32_t);
- break;
- case 'f':
- if ((argv[i] = xmlRpcValueNew(XML_RPC_DOUBLE)))
- argv[i]->value.real = va_arg(ap, double);
- break;
- case 'b':
- if ((argv[i] = xmlRpcValueNew(XML_RPC_BOOLEAN)))
- argv[i]->value.boolean = va_arg(ap, int);
- break;
- case 's':
- if ((argv[i] = xmlRpcValueNew(XML_RPC_STRING)))
- argv[i]->value.string = strdup(va_arg(ap, const char *));
- break;
- default:
- argv[i] = NULL;
- break;
- }
- if (argv[i]==NULL) {
- xmlRpcArgvFree(i, argv);
- return NULL;
- }
- i++;
- }
- return argv;
-}
-
-void
-xmlRpcArgvFree(int argc, xmlRpcValuePtr *argv)
-{
- int i;
- if (!argv)
- return;
- for (i = 0; i < argc; i++)
- xmlRpcValueFree(argv[i]);
-
- VIR_FREE(argv);
-}
-
-int xmlRpcCall(xmlRpcContextPtr context, const char *method,
- const char *retfmt, const char *fmt, ...)
-{
- va_list ap;
- int argc;
- xmlRpcValuePtr *argv;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
- char *ret;
- xmlDocPtr xml;
- xmlNodePtr node;
- bool fault;
- xmlRpcValuePtr value;
- void *retval = NULL;
- char *content;
-
- va_start(ap, fmt);
-
- if (retfmt && *retfmt)
- retval = va_arg(ap, void *);
-
- if (!(argv = xmlRpcArgvNew(fmt, ap, &argc)))
- return -1;
-
- va_end(ap);
-
- xmlRpcMarshalRequest(method, &buf, argc, argv);
-
- xmlRpcArgvFree(argc, argv);
-
- if (virBufferError(&buf))
- return -1;
-
- content = virBufferContentAndReset(&buf);
- ret = xmlRpcCallRaw(context->uri, content);
- VIR_FREE(content);
-
- if (!ret)
- return -1;
-
- xml = xmlReadDoc((const xmlChar *)ret, "response.xml", NULL,
- XML_PARSE_NOENT | XML_PARSE_NONET |
- XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
- VIR_FREE(ret);
-
- if (xml == NULL) {
- errno = EINVAL;
- xmlRpcError(VIR_ERR_XML_ERROR, _("parse server response failed"), 0);
- return -1;
- }
-
- node = xmlDocGetRootElement(xml);
-
- value = xmlRpcUnmarshalResponse(node, &fault);
-
- if (!fault) {
- switch (*retfmt) {
- case 'i':
- if (value->kind == XML_RPC_INTEGER)
- *(int32_t *)retval = value->value.integer;
- break;
- case 'b':
- if (value->kind == XML_RPC_BOOLEAN)
- *(bool *)retval = value->value.boolean;
- break;
- case 'f':
- if (value->kind == XML_RPC_DOUBLE)
- *(double *)retval = value->value.real;
- break;
- case 's':
- if (value->kind == XML_RPC_STRING)
- *(char **)retval = strdup(value->value.string);
- break;
- case 'S':
- *(char ***)retval = xmlRpcStringArray(value);
- break;
- case 'V':
- *(xmlRpcValuePtr *)retval = value;
- value = NULL;
- break;
- default:
- printf("not supported yet\n");
- break;
- }
- }
-
- xmlFreeDoc(xml);
-
- if (fault) {
- /* FIXME we need generic dict routines */
- /* FIXME we need faultMessage propagate to libvirt error API */
- context->faultCode = value->value.dict.root->value->value.integer;
- context->faultMessage = strdup(value->value.dict.root->next->value->value.string);
- xmlRpcValueFree(value);
- errno = EFAULT;
- return -1;
- }
-
- xmlRpcValueFree(value);
-
- return 0;
-}
-
-xmlRpcContextPtr xmlRpcContextNew(const char *uri)
-{
- xmlRpcContextPtr ret;
-
- if (VIR_ALLOC(ret) < 0) {
- xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate new context"), sizeof(*ret));
- } else {
- ret->uri = strdup(uri);
- ret->faultMessage = NULL;
- }
-
- return ret;
-}
-
-void xmlRpcContextFree(xmlRpcContextPtr context)
-{
- if (context) {
- VIR_FREE(context->uri);
- VIR_FREE(context->faultMessage);
- VIR_FREE(context);
- }
-}
-
-int xmlRpcContextFaultCode(xmlRpcContextPtr context)
-{
- return context->faultCode;
-}
-
-const char *xmlRpcContextFaultMessage(xmlRpcContextPtr context)
-{
- return context->faultMessage;
-}
diff --git a/src/xmlrpc.h b/src/xmlrpc.h
deleted file mode 100644
index 2a9c92a..0000000
--- a/src/xmlrpc.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * xmlrpc.c: XML-RPC protocol handler for libvir library
- *
- * Copyright (C) 2006 IBM, Corp.
- *
- * See COPYING.LIB for the License of this software
- *
- * Anthony Liguori <aliguori(a)us.ibm.com>
- */
-
-#ifndef _VIR_XML_RPC_H_
-#define _VIR_XML_RPC_H_
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <stdbool.h>
-#include <stdint.h>
-#include <time.h>
-#include <stdarg.h>
-
-#include "buf.h"
-
-typedef enum _xmlRpcValueType xmlRpcValueType;
-
-typedef struct _xmlRpcValueArray xmlRpcValueArray;
-typedef struct _xmlRpcValueDictElement xmlRpcValueDictElement;
-typedef struct _xmlRpcValueDict xmlRpcValueDict;
-typedef struct _xmlRpcValueBase64 xmlRpcValueBase64;
-typedef struct _xmlRpcValue xmlRpcValue;
-typedef struct _xmlRpcContext xmlRpcContext;
-
-typedef xmlRpcValueArray *xmlRpcValueArrayPtr;
-typedef xmlRpcValueDictElement *xmlRpcValueDictElementPtr;
-typedef xmlRpcValueDict *xmlRpcValueDictPtr;
-typedef xmlRpcValueBase64 *xmlRpcValueBase64Ptr;
-typedef xmlRpcValue *xmlRpcValuePtr;
-typedef xmlRpcContext *xmlRpcContextPtr;
-
-enum _xmlRpcValueType {
- XML_RPC_ARRAY,
- XML_RPC_STRUCT,
- XML_RPC_INTEGER,
- XML_RPC_DOUBLE,
- XML_RPC_BOOLEAN,
- XML_RPC_DATE_TIME,
- XML_RPC_BASE64,
- XML_RPC_STRING,
- XML_RPC_NIL,
-};
-
-struct _xmlRpcValueArray {
- int n_elements;
- xmlRpcValuePtr *elements;
-};
-
-struct _xmlRpcValueDictElement {
- char *name;
- xmlRpcValuePtr value;
- xmlRpcValueDictElementPtr next;
-};
-
-struct _xmlRpcValueDict {
- xmlRpcValueDictElementPtr root;
-};
-
-struct _xmlRpcValueBase64 {
- void *data;
- size_t n_data;
-};
-
-struct _xmlRpcValue {
- xmlRpcValueType kind;
-
- union {
- char *string;
- xmlRpcValueArray array;
- xmlRpcValueDict dict;
- int32_t integer;
- double real;
- bool boolean;
- time_t dateTime;
- xmlRpcValueBase64 base64;
- } value;
-};
-
-struct _xmlRpcContext;
-
-xmlRpcValuePtr *xmlRpcArgvNew(const char *fmt, va_list ap, int *argc);
-void xmlRpcArgvFree(int argc, xmlRpcValuePtr *argv);
-
-void xmlRpcMarshalRequest(const char *request,
- virBufferPtr buf,
- int argc, xmlRpcValuePtr *argv);
-
-xmlRpcValuePtr xmlRpcUnmarshalResponse(xmlNodePtr node, bool *is_fault);
-
-void xmlRpcValueMarshal(xmlRpcValuePtr value, virBufferPtr buf, int indent);
-
-xmlRpcValuePtr xmlRpcValueUnmarshal(xmlNodePtr node);
-
-void xmlRpcValueFree(xmlRpcValuePtr value);
-
-int xmlRpcCall(xmlRpcContextPtr context, const char *method,
- const char *retval, const char *fmt, ...);
-
-xmlRpcContextPtr xmlRpcContextNew(const char *uri);
-
-void xmlRpcContextFree(xmlRpcContextPtr context);
-
-int xmlRpcContextFaultCode(xmlRpcContextPtr context);
-
-const char *xmlRpcContextFaultMessage(xmlRpcContextPtr context);
-
-#endif
diff --git a/tests/.cvsignore b/tests/.cvsignore
index e45c3dc..679cc20 100644
--- a/tests/.cvsignore
+++ b/tests/.cvsignore
@@ -2,7 +2,6 @@ Makefile
Makefile.in
.deps
.libs
-xmlrpctest
sexpr2xmltest
xml2sexprtest
virshtest
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9e794c5..87e4235 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -38,13 +38,12 @@ LDADDS = \
EXTRA_DIST = \
oomtrace.pl \
test-lib.sh \
- xmlrpcserver.py \
qemuxml2argvdata \
nodeinfodata \
domainschematest \
domainschemadata
-noinst_PROGRAMS = xmlrpctest virshtest conftest \
+noinst_PROGRAMS = virshtest conftest \
nodeinfotest statstest qparamtest
if WITH_XEN
@@ -111,15 +110,6 @@ TESTS_ENVIRONMENT = \
valgrind:
$(MAKE) check VG="valgrind --quiet --leak-check=full --suppressions=$(srcdir)/.valgrind.supp"
-# Note: xmlrpc.[c|h] is not in libvirt yet
-xmlrpctest_SOURCES = \
- xmlrpctest.c \
- testutils.c testutils.h \
- @top_srcdir(a)/src/xmlrpc.c \
- @top_srcdir(a)/src/xmlrpc.h
-
-xmlrpctest_LDADD = $(LDADDS)
-
if WITH_XEN
xml2sexprtest_SOURCES = \
xml2sexprtest.c testutilsxen.c testutilsxen.h \
diff --git a/tests/test_xmlrpc.sh b/tests/test_xmlrpc.sh
deleted file mode 100755
index ccdfdbc..0000000
--- a/tests/test_xmlrpc.sh
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/bash
-
-./xmlrpcserver.py >/dev/null 2>&1 &
-sleep 1
-./xmlrpctest
-pkill -f xmlrpcserver.py >/dev/null 2>&1 &
diff --git a/tests/xmlrpcserver.py b/tests/xmlrpcserver.py
deleted file mode 100755
index debff93..0000000
--- a/tests/xmlrpcserver.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env python
-
-#
-# xmlrpcserver.py: simple server for XML-RPC tests
-#
-# Copyright (C) 2005 Red Hat, Inc.
-#
-# See COPYING.LIB for the License of this software
-#
-# Karel Zak <kzak(a)redhat.com>
-#
-# $Id$
-#
-#
-# simple client:
-#
-# >>> import xmlrpclib
-# >>> s=xmlrpclib.Server('http://localhost:8000')
-# >>> s.plus(10,10)
-# 20
-#
-
-import sys
-from SimpleXMLRPCServer import SimpleXMLRPCServer
-
-SERVER_PORT = 8000
-
-
-class VirtRPCServer(SimpleXMLRPCServer):
- def _dispatch(self, method, params):
- try:
- func = getattr(self, 'test_' + method)
- except AttributeError:
- raise Exception('method "%s" is not supported' % method)
- else:
- return func(*params)
-
- def test_plus(self, x, y):
- return x + y
-
-
-server = VirtRPCServer(("localhost", SERVER_PORT))
-server.serve_forever()
-
-
-
-# vim: set tabstop=4:
-# vim: set shiftwidth=4:
-# vim: set expandtab:
diff --git a/tests/xmlrpctest.c b/tests/xmlrpctest.c
deleted file mode 100644
index bc8eb8a..0000000
--- a/tests/xmlrpctest.c
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * xmlrpctest.c: simple client for XML-RPC tests
- *
- * Copyright (C) 2005, 2008 Red Hat, Inc.
- *
- * See COPYING.LIB for the License of this software
- *
- * Karel Zak <kzak(a)redhat.com>
- *
- * $Id$
- */
-
-#include <config.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <limits.h>
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-#include <libxml/xpath.h>
-
-#include "internal.h"
-#include "buf.h"
-#include "xmlrpc.h"
-
-#include "testutils.h"
-
-
-#define NLOOPS 100 /* default number of loops per test */
-
-static char *progname;
-
-
-static int
-testMethodPlusINT(const void *data)
-{
- int retval = 0;
- xmlRpcContextPtr cxt = (xmlRpcContextPtr) data;
-
- if (xmlRpcCall(cxt, "plus", "i", "ii",
- (const char *) &retval, 10, 10) < 0)
- return -1;
-
- return retval==(10+10) ? 0 : -1;
-}
-
-static int
-testMethodPlusDOUBLE(const void *data)
-{
- double retval = 0;
- xmlRpcContextPtr cxt = (xmlRpcContextPtr) data;
-
- if (xmlRpcCall(cxt, "plus", "f", "ff",
- (const char *) &retval, 10.1234, 10.1234) < 0)
- return -1;
-
- return retval==(10.1234+10.1234) ? 0 : -1;
-}
-
-static void
-marshalRequest(virBufferPtr buf, const char *fmt, ...)
-{
- int argc;
- xmlRpcValuePtr *argv;
- va_list ap;
-
- va_start(ap, fmt);
- argv = xmlRpcArgvNew(fmt, ap, &argc);
- va_end(ap);
-
- xmlRpcMarshalRequest("test", buf, argc, argv);
-
- xmlRpcArgvFree(argc, argv);
-}
-
-static int
-checkRequestValue(const char *xmlstr, const char *xpath, int type, void *expected)
-{
- xmlDocPtr xml = NULL;
- xmlXPathContextPtr ctxt = NULL;
- xmlXPathObjectPtr obj = NULL;
- int ret = -1;
-
- xml = xmlReadDoc((const xmlChar *) xmlstr, "xmlrpctest.xml", NULL,
- XML_PARSE_NOENT | XML_PARSE_NONET |
- XML_PARSE_NOERROR | XML_PARSE_NOWARNING);
- if (!xml)
- goto error;
-
- if (!(ctxt = xmlXPathNewContext(xml)))
- goto error;
-
- if (!(obj = xmlXPathEval(BAD_CAST xpath, ctxt)))
- goto error;
-
- switch(type) {
- case XML_RPC_INTEGER:
- if ((obj->type != XPATH_NUMBER) ||
- ((int) obj->floatval != *((int *)expected)))
- goto error;
- break;
- case XML_RPC_DOUBLE:
- if ((obj->type != XPATH_NUMBER) ||
- ((double) obj->floatval != *((double *)expected)))
- goto error;
- break;
- case XML_RPC_STRING:
- if ((obj->type != XPATH_STRING) ||
- (STRNEQ((const char *)obj->stringval, (const char *)expected)))
- goto error;
- break;
- default:
- goto error;
- }
- ret = 0;
-
-error:
- xmlXPathFreeObject(obj);
- xmlXPathFreeContext(ctxt);
- if (xml)
- xmlFreeDoc(xml);
- return ret;
-}
-
-static int
-testMarshalRequestINT(const void *data)
-{
- int num = INT_MAX;
- int ret = 0;
- int check = data ? *((int *)data) : 0;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
- marshalRequest(&buf, "i", num);
- char *content;
-
- if (virBufferError(&buf))
- return -1;
-
- content = virBufferContentAndReset(&buf);
-
- if (check)
- ret = checkRequestValue(content,
- "number(/methodCall/params/param[1]/value/int)",
- XML_RPC_INTEGER, (void *) &num);
-
- free(content);
- return ret;
-}
-
-static int
-testMarshalRequestSTRING(const void *data ATTRIBUTE_UNUSED)
-{
- const char *str = "This library will be really sexy.";
- int ret = 0;
- int check = data ? *((int *)data) : 0;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
- char *content;
-
- marshalRequest(&buf, "s", str);
-
- if (virBufferError(&buf))
- return -1;
-
- content = virBufferContentAndReset(&buf);
- if (check)
- ret = checkRequestValue(content,
- "string(/methodCall/params/param[1]/value/string)",
- XML_RPC_STRING, (void *) str);
-
- free(content);
- return ret;
-}
-
-static int
-testMarshalRequestDOUBLE(const void *data)
-{
- double num = 123456789.123;
- int ret = 0;
- int check = data ? *((int *)data) : 0;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
- char *content;
-
- marshalRequest(&buf, "f", num);
-
- if (virBufferError(&buf))
- return -1;
-
- content = virBufferContentAndReset(&buf);
- if (check)
- ret = checkRequestValue(content,
- "number(/methodCall/params/param[1]/value/double)",
- XML_RPC_DOUBLE, (void *) &num);
-
- free(content);
- return ret;
-}
-
-
-int
-main(int argc, char **argv)
-{
- xmlRpcContextPtr cxt = NULL;
- int check = 1;
- int ret = 0;
- const char *url = "http://localhost:8000";
-
- progname = argv[0];
-
- if (argc > 2)
- {
- fprintf(stderr, "Usage: %s [url]\n", progname);
- exit(EXIT_FAILURE);
- }
- if (argc == 2)
- url = argv[1];
-
- /*
- * client-server tests
- */
- if (!(cxt = xmlRpcContextNew(url)))
- {
- fprintf(stderr, "%s: failed create new RPC context\n", progname);
- exit(EXIT_FAILURE);
- }
-
- if (virtTestRun("XML-RPC methodCall INT+INT",
- NLOOPS, testMethodPlusINT, (const void *) cxt) != 0)
- ret = -1;
-
- if (virtTestRun("XML-RPC methodCall DOUBLE+DOUBLE",
- NLOOPS, testMethodPlusDOUBLE, (const void *) cxt) != 0)
- ret = -1;
-
- xmlRpcContextFree(cxt);
-
- /*
- * regression / performance tests
- */
- if (virtTestRun("XML-RPC request marshalling: INT (check)",
- 1, testMarshalRequestINT, (const void *) &check) != 0)
- ret = -1;
- if (virtTestRun("XML-RPC request marshalling: INT",
- NLOOPS, testMarshalRequestINT, NULL) != 0)
- ret = -1;
-
- if (virtTestRun("XML-RPC request marshalling: DOUBLE (check)",
- 1, testMarshalRequestDOUBLE, (const void *) &check) != 0)
- ret = -1;
- if (virtTestRun("XML-RPC request marshalling: DOUBLE",
- NLOOPS, testMarshalRequestDOUBLE, NULL) != 0)
- ret = -1;
-
- if (virtTestRun("XML-RPC request marshalling: STRING (check)",
- 1, testMarshalRequestSTRING, (void *) &check) != 0)
- ret = -1;
- if (virtTestRun("XML-RPC request marshalling: STRING",
- NLOOPS, testMarshalRequestSTRING, NULL) != 0)
- ret = -1;
-
- exit(ret==0 ? EXIT_SUCCESS : EXIT_FAILURE);
-}
-
-
-/*
- * vim: set tabstop=4:
- * vim: set shiftwidth=4:
- * vim: set expandtab:
- */
--
1.6.0.4.1044.g77718
16 years
[libvirt] [PATCH] libvirtd: plug a nominal leak
by Jim Meyering
Running make check through valgrind exposed this:
40 bytes in 1 blocks are definitely lost in loss record 9 of 68
at 0x4A05174: calloc (vg_replace_malloc.c:397)
by 0x4C422C1: virAllocN (memory.c:128)
by 0x412CB1: qemudRunLoop (qemud.c:1846)
by 0x41480B: main (qemud.c:2469)
Here's the fix:
>From a660df67d623184001a74f5fcf88a2f58217ec29 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 11 Dec 2008 19:58:08 +0100
Subject: [PATCH] libvirtd: plug a nominal leak
* qemud/qemud.c (qemudRunLoop): Free server->workers.
---
qemud/qemud.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/qemud/qemud.c b/qemud/qemud.c
index f35d0fd..80b8778 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -1919,6 +1919,7 @@ static int qemudRunLoop(struct qemud_server *server) {
pthread_mutex_lock(&server->lock);
}
+ free(server->workers);
pthread_mutex_unlock(&server->lock);
return ret;
}
--
1.6.0.4.1044.g77718
16 years