[libvirt] [PATCH] virsh: Enhance documentation of commands starting jobs
by Jiri Denemark
Some virsh commands start a (long-running) job that can be monitored
using domjobinfo and aborted with domjobabort. Let's be explicit about
this in virsh man page.
---
tools/virsh.pod | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 43ed1ea..fbde57f 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -627,30 +627,35 @@ named by I<format> to a domain XML format.
Convert the file I<xml> in domain XML format to the native guest
configuration format named by I<format>.
=item B<dump> I<domain-id> I<corefilepath> [I<--live>] [I<--crash>]
[I<--bypass-cache>]
Dumps the core of a domain to a file for analysis.
If I<--live> is specified, the domain continues to run until the core
dump is complete, rather than pausing up front.
If I<--crash> is specified, the domain is halted with a crashed status,
rather than merely left in a paused state.
If I<--bypass-cache> is specified, the save will avoid the file system
cache, although this may slow down the operation.
+The progress may be monitored using B<domjobinfo> virsh command and canceled
+with B<domjobabort> command (sent by another virsh instance). Interrupting
+(usually with C<Ctrl-C>) the virsh process which runs B<dump> command is not
+enough to actually cancel the operation.
+
NOTE: Some hypervisors may require the user to manually ensure proper
permissions on file and path specified by argument I<corefilepath>.
=item B<dumpxml> I<domain-id> [I<--inactive>] [I<--security-info>]
[I<--update-cpu>]
Output the domain information as an XML dump to stdout, this format can be used
by the B<create> command. Additional options affecting the XML dump may be
used. I<--inactive> tells virsh to dump domain configuration that will be used
on next start of the domain as opposed to the current domain configuration.
Using I<--security-info> will also include security sensitive information
in the XML dump. I<--update-cpu> updates domain CPU requirements according to
host CPU.
=item B<echo> [I<--shell>] [I<--xml>] [I<arg>...]
@@ -672,30 +677,35 @@ This is equivalent to:
except that it does some error checking.
The editor used can be supplied by the C<$VISUAL> or C<$EDITOR> environment
variables, and defaults to C<vi>.
=item B<managedsave> I<domain-id> [I<--bypass-cache>]
[{I<--running> | I<--paused>}]
Save and destroy (stop) a running domain, so it can be restarted from the same
state at a later time. When the virsh B<start> command is next run for
the domain, it will automatically be started from this saved state.
If I<--bypass-cache> is specified, the save will avoid the file system
cache, although this may slow down the operation.
+The progress may be monitored using B<domjobinfo> virsh command and canceled
+with B<domjobabort> command (sent by another virsh instance). Interrupting
+(usually with C<Ctrl-C>) the virsh process which runs B<managedsave> command
+is not enough to actually cancel the operation.
+
Normally, starting a managed save will decide between running or paused
based on the state the domain was in when the save was done; passing
either the I<--running> or I<--paused> flag will allow overriding which
state the B<start> should use.
The B<dominfo> command can be used to query whether a domain currently
has any managed save image.
=item B<managedsave-remove> I<domain-id>
Remove the B<managedsave> state file for a domain, if it exists. This
ensures the domain will do a full boot the next time it is started.
=item B<maxvcpus> [I<type>]
@@ -724,30 +734,33 @@ used to reject the migration if the hypervisor lacks change protection
support. I<--verbose> displays the progress of migration.
The I<desturi> is the connection URI of the destination host, and
I<migrateuri> is the migration URI, which usually can be omitted.
I<dname> is used for renaming the domain to new name during migration, which
also usually can be omitted. Likewise, I<--xml> B<file> is usually
omitted, but can be used to supply an alternative XML file for use on
the destination to supply a larger set of changes to any host-specific
portions of the domain XML, such as accounting for naming differences
between source and destination in accessing underlying storage.
I<--timeout> B<seconds> forces guest to suspend when live migration exceeds
that many seconds, and
then the migration will complete offline. It can only be used with I<--live>.
+Running migration can be canceled by interrupting virsh (usually using
+C<Ctrl-C>) or by B<domjobabort> command sent from another virsh instance.
+
B<Note>: The I<desturi> parameter for normal migration and peer2peer migration
has different semantics:
=over 4
=item * normal migration: the I<desturi> is an address of the target host as
seen from the client machine.
=item * peer2peer migration: the I<desturi> is an address of the target host as
seen from the source machine.
=back
=item B<migrate-setmaxdowntime> I<domain-id> I<downtime>
@@ -797,30 +810,35 @@ B<Note>: To avoid corrupting file system contents within the domain, you
should not reuse the saved state file for a second B<restore> unless you
have also reverted all storage volumes back to the same contents as when
the state file was created.
=item B<save> I<domain-id> I<state-file> [I<--bypass-cache>] [I<--xml> B<file>]
[{I<--running> | I<--paused>}]
Saves a running domain (RAM, but not disk state) to a state file so that
it can be restored
later. Once saved, the domain will no longer be running on the
system, thus the memory allocated for the domain will be free for
other domains to use. B<virsh restore> restores from this state file.
If I<--bypass-cache> is specified, the save will avoid the file system
cache, although this may slow down the operation.
+The progress may be monitored using B<domjobinfo> virsh command and canceled
+with B<domjobabort> command (sent by another virsh instance). Interrupting
+(usually with C<Ctrl-C>) the virsh process which runs B<save> command is not
+enough to actually cancel the operation.
+
This is roughly equivalent to doing a hibernate on a running computer,
with all the same limitations. Open network connections may be
severed upon restore, as TCP timeouts may have expired.
I<--xml> B<file> is usually omitted, but can be used to supply an
alternative XML file for use on the restored guest with changes only
in the host-specific portions of the domain XML. For example, it can
be used to account for file naming differences that are planned to
be made via disk snapshots of underlying storage after the guest is saved.
Normally, restoring a saved image will decide between running or paused
based on the state the domain was in when the save was done; passing
either the I<--running> or I<--paused> flag will allow overriding which
state the B<restore> should use.
--
1.7.6.1
13 years, 2 months
[libvirt] [libvirt-glib] Ability to create new domains
by Zeeshan Ali (Khattak)
From: "Zeeshan Ali (Khattak)" <zeeshanak(a)gnome.org>
---
libvirt-gobject/libvirt-gobject-connection.c | 38 ++++++++++++++++++++++++++
libvirt-gobject/libvirt-gobject-connection.h | 3 ++
libvirt-gobject/libvirt-gobject.sym | 1 +
3 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/libvirt-gobject/libvirt-gobject-connection.c b/libvirt-gobject/libvirt-gobject-connection.c
index 32f749c..072484e 100644
--- a/libvirt-gobject/libvirt-gobject-connection.c
+++ b/libvirt-gobject/libvirt-gobject-connection.c
@@ -720,3 +720,41 @@ GVirStream *gvir_connection_get_stream(GVirConnection *self,
return klass->stream_new(self, st);
}
+
+/**
+ * gvir_connection_create_domain:
+ * @conn: the connection on which to create the dmain
+ * @conf: the configuration for the new domain
+ * Returns: (transfer full): the newly created domain
+ */
+GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
+ GVirConfigDomain *conf,
+ GError **err)
+{
+ const gchar *xml;
+ virDomainPtr handle;
+ GVirConnectionPrivate *priv = conn->priv;
+
+ xml = gvir_config_object_get_doc(GVIR_CONFIG_OBJECT(conf));
+
+ g_return_val_if_fail(xml != NULL, NULL);
+
+ if (!(handle = virDomainDefineXML(priv->conn, xml))) {
+ *err = gvir_error_new_literal(GVIR_CONNECTION_ERROR,
+ 0,
+ "Failed to create domain");
+ return NULL;
+ }
+
+ GVirDomain *domain;
+
+ domain = GVIR_DOMAIN(g_object_new(GVIR_TYPE_DOMAIN,
+ "handle", handle,
+ NULL));
+
+ g_hash_table_insert(priv->domains,
+ g_strdup(gvir_domain_get_uuid(domain)),
+ domain);
+
+ return domain;
+}
diff --git a/libvirt-gobject/libvirt-gobject-connection.h b/libvirt-gobject/libvirt-gobject-connection.h
index 0172d02..c453bed 100644
--- a/libvirt-gobject/libvirt-gobject-connection.h
+++ b/libvirt-gobject/libvirt-gobject-connection.h
@@ -107,6 +107,9 @@ GVirDomain *gvir_connection_find_domain_by_id(GVirConnection *conn,
GVirDomain *gvir_connection_find_domain_by_name(GVirConnection *conn,
const gchar *name);
+GVirDomain *gvir_connection_create_domain(GVirConnection *conn,
+ GVirConfigDomain *conf,
+ GError **err);
#if 0
GList *gvir_connection_get_interfaces(GVirConnection *conn);
diff --git a/libvirt-gobject/libvirt-gobject.sym b/libvirt-gobject/libvirt-gobject.sym
index a68db4b..eae40a2 100644
--- a/libvirt-gobject/libvirt-gobject.sym
+++ b/libvirt-gobject/libvirt-gobject.sym
@@ -18,6 +18,7 @@ LIBVIRT_GOBJECT_0.0.1 {
gvir_connection_get_domain;
gvir_connection_find_domain_by_id;
gvir_connection_find_domain_by_name;
+ gvir_connection_create_domain;
gvir_domain_get_type;
gvir_domain_handle_get_type;
--
1.7.6.2
13 years, 2 months
[libvirt] [PATCH] virLockManagerNopInit: Rename flags to unused_flags
by Michal Privoznik
As these might be not used and make syntax-check complains about checking
them via virCheckFlags.
---
pushing under build-breaker rule
src/locking/lock_driver_nop.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/locking/lock_driver_nop.c b/src/locking/lock_driver_nop.c
index 570b7e7..2ca6c4d 100644
--- a/src/locking/lock_driver_nop.c
+++ b/src/locking/lock_driver_nop.c
@@ -29,10 +29,10 @@
static int virLockManagerNopInit(unsigned int version ATTRIBUTE_UNUSED,
const char *configFile ATTRIBUTE_UNUSED,
- unsigned int flags ATTRIBUTE_UNUSED)
+ unsigned int flags_unused ATTRIBUTE_UNUSED)
{
VIR_DEBUG("version=%u configFile=%s flags=%x",
- version, NULLSTR(configFile), flags);
+ version, NULLSTR(configFile), flags_unused);
return 0;
}
--
1.7.3.4
13 years, 2 months
[libvirt] LPC2011 Virtualization Micro Conf
by Jes Sorensen
Hi,
With the success of last year's Virtualization micro-conference track
at Linux Plumbers 2010, I have accepted to organize a similar track
for Linux Plumbers 2011 in Santa Rosa. Please see the official Linux
Plumbers 2011 website for full details about the conference:
http://www.linuxplumbersconf.org/2011/
The Linux Plumbers 2011 Virtualization track is focusing on general
free software Linux Virtualization. It is not reserved for a specific
hypervisor, but will focus on general virtualization issues and in
particular collaboration amongst projects. This would include KVM,
Xen, QEMU, containers etc.
Deadline:
---------
The deadline for submissions is April 30th. Please visit the following
link to submit your proposal:
http://www.linuxplumbersconf.org/2011/ocw/events/LPC2011MC/proposals
Example topics:
---------------
- Kernel and Hypervisor KVM/QEMU/Xen interaction
- QEMU integration, sharing of code between the different projects
- IO Performance and scalability
- Live Migration
- Managing and supporting enterprise storage
- Support for new hardware features, and/or provide guest access to
these features.
- Guest agents
- Virtualization management tools, libvirt, etc.
- Desktop integration
- Consumer Electronics device emulation
- Custom platform configuration and coordination with the kernel
Audience:
---------
Virtualization hypervisor developers, developers of virtualization
management tools and applications, embedded virtualization developers,
vendors and others.
Best regards,
Jes
13 years, 2 months
[libvirt] [PATCH v2] daemon: Update libvirtd SysV/upstart scripts to avoid confusion
by Peter Krempa
On some systems init scripts are installed along with upstart . This may
cause trouble if user tries to restart/stop a instance of libvirtd
managed with upstart with init script.
Upstart config file uses "respawn" stanza to ensure that libvirtd is
restarted after a crash/kill. This combined with a
The SysV init script is now able to detect libvirtd managed with upstart
explicitly and notify the user about this. This patch also modifies the
way the PID file is handled. Libvirtd alone removes the pid file on a
successful exit, so now, the init script does not delete it. It's only
deleted while starting libvirtd, when the script detects, that no
libvirtd with pid specified in the pid file is running.
This patch also modifies the upstart configuration file for libvirt.
Same logic as in the SysV script for handling pid files is used. The
upstart script does not explicitly check for a SysV managed instance.
Upstart alone prohibits to stop a not-started instance, so this issue is
handled automaticaly.
https://bugzilla.redhat.com/show_bug.cgi?id=728153
---
initctl_check() in the SysV init file is not strongly required. The purpose
of this is to notify the user of the source of problem the user is experiencing.
It can be left out, but then no (reasonable) notification will be provided
and the user might kill libvirtd managed by upstart (which will thereafter
respawn)
daemon/libvirtd.init.in | 43 +++++++++++++++++++++++++++++++++++++++++--
daemon/libvirtd.upstart | 31 ++++++++++++++++++++++++-------
2 files changed, 65 insertions(+), 9 deletions(-)
diff --git a/daemon/libvirtd.init.in b/daemon/libvirtd.init.in
index 0697a2b..28801d1 100644
--- a/daemon/libvirtd.init.in
+++ b/daemon/libvirtd.init.in
@@ -43,6 +43,8 @@ LIBVIRTD_CONFIG=
LIBVIRTD_ARGS=
KRB5_KTNAME=/etc/libvirt/krb5.tab
+INITCTL_PATH=/sbin/initctl
+
test -f @sysconfdir@/sysconfig/libvirtd && . @sysconfdir@/sysconfig/libvirtd
export QEMU_AUDIO_DRV
@@ -56,8 +58,45 @@ fi
RETVAL=0
+# Check if libvirt is managed by upstart and fail if it's the case
+initctl_check() {
+ if [ -x $INITCTL_PATH ]; then
+ #extract status from upstart
+ LIBVIRTD_UPSTART_STATUS=`$INITCTL_PATH status libvirtd | tr "/" " " | cut -d " " -f 2`
+ if [ $LIBVIRTD_UPSTART_STATUS = "start" ]; then
+ logger -t "libvirtd" -s "libvirtd is managed by upstart and started, use initctl instead"
+ exit 1
+ fi
+ fi
+}
+
+# test if a pidfile exists and if there's a libvirtd process associated with it
+pidfile_check() {
+ #check if libvirtd is running
+ if [ -f "$PIDFILE" ]; then
+ PID=`cat $PIDFILE`
+ if [ -n "$PID" ]; then
+ PROCESSES=`pidof $PROCESS | grep $PID`
+ if [ -n "$PROCESSES" ]; then
+ logger -t "libvirtd" -s "$SERVICE with pid $PID is running";
+ exit 1
+ else
+ # pidfile exists but no running libvirtd found
+ # remove stuck pidfile
+ rm -f $PIDFILE
+ fi
+ else
+ # pidfile is empty
+ rm -f $PIDFILE
+ fi
+ fi
+}
+
start() {
echo -n $"Starting $SERVICE daemon: "
+ initctl_check
+ pidfile_check
+
mkdir -p @localstatedir@/cache/libvirt
rm -rf @localstatedir@/cache/libvirt/*
KRB5_KTNAME=$KRB5_KTNAME daemon --pidfile $PIDFILE --check $SERVICE $PROCESS --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
@@ -68,14 +107,13 @@ start() {
stop() {
echo -n $"Stopping $SERVICE daemon: "
+ initctl_check
killproc -p $PIDFILE $PROCESS
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
rm -f @localstatedir@/lock/subsys/$SERVICE
- rm -f $PIDFILE
- rm -rf @localstatedir@/cache/libvirt/*
else
exit $RETVAL
fi
@@ -88,6 +126,7 @@ restart() {
reload() {
echo -n $"Reloading $SERVICE configuration: "
+ initctl_check
killproc -p $PIDFILE $PROCESS -HUP
RETVAL=$?
diff --git a/daemon/libvirtd.upstart b/daemon/libvirtd.upstart
index fd1d951..c506d45 100644
--- a/daemon/libvirtd.upstart
+++ b/daemon/libvirtd.upstart
@@ -7,6 +7,29 @@ stop on runlevel [!345]
respawn
+pre-start script
+ PIDFILE=/var/run/libvirtd.pid
+ #check if libvirtd is running
+ if [ -f "$PIDFILE" ]; then
+ PID=`cat $PIDFILE`
+ if [ -n "$PID" ]; then
+ PROCESSES=`pidof libvirtd | grep $PID`
+
+ if [ -n "$PROCESSES" ]; then
+ logger -t "libvirtd" -s "error: libvirtd is already running with pid $PID"
+ stop
+ exit 0
+ else
+ # remove stuck pidfile
+ rm -f $PIDFILE
+ fi
+ else
+ # empty pidfile
+ rm -f $PIDFILE
+ fi
+ fi
+end script
+
script
LIBVIRTD_CONFIG=
LIBVIRTD_ARGS=
@@ -31,16 +54,10 @@ script
ulimit -c "$DAEMON_COREFILE_LIMIT"
fi
- # Clean up a pidfile that might be left around
- rm -f /var/run/libvirtd.pid
-
+ # No pid file and/or libvirtd not running.
mkdir -p /var/cache/libvirt
rm -rf /var/cache/libvirt/*
exec /usr/sbin/libvirtd $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
end script
-post-stop script
- rm -f $PIDFILE
- rm -rf /var/cache/libvirt/*
-end script
--
1.7.3.4
13 years, 2 months
[libvirt] [PATCH v3] qemu: Allow domain reboot after core dump
by Michal Privoznik
This patch introduces possibility to reboot domain after core dump
finishes. The new flag VIR_DUMP_REBOOT was added to
virDomainCoreDumpFlags. The new functionality is accessible via virsh
too: virsh dump --reboot <domain>
---
diff to v2:
-issue reset command instead of qemuDomainReboot
include/libvirt/libvirt.h.in | 1 +
src/qemu/qemu_driver.c | 54 +++++++++++++++++++++++++++++++++++++++--
tools/virsh.c | 3 ++
3 files changed, 55 insertions(+), 3 deletions(-)
diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 39155a6..8c41f5a 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -748,6 +748,7 @@ typedef enum {
VIR_DUMP_CRASH = (1 << 0), /* crash after dump */
VIR_DUMP_LIVE = (1 << 1), /* live dump */
VIR_DUMP_BYPASS_CACHE = (1 << 2), /* avoid file system cache pollution */
+ VIR_DUMP_REBOOT = (1 << 3), /* reboot domain after dump finishes */
} virDomainCoreDumpFlags;
/* Domain migration flags. */
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index 0d0bea2..3e05e14 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -2860,6 +2860,47 @@ getCompressionType(struct qemud_driver *driver)
return compress;
}
+static int
+doSystemReset(struct qemud_driver *driver,
+ virDomainObjPtr *vm)
+{
+ int ret = -1;
+ qemuDomainObjPrivatePtr priv;
+
+ /* Okay, this should never happen, but doesn't hurt to check. */
+ if (!driver || !vm || !*vm) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("invalid argument supplied"));
+ goto cleanup;
+ }
+
+ priv = (*vm)->privateData;
+
+ if (qemuDomainObjBeginJob(driver, *vm, QEMU_JOB_MODIFY) < 0)
+ goto cleanup;
+
+ if (!virDomainObjIsActive(*vm)) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("guest unexpectedly quit"));
+ goto endjob;
+ }
+
+ qemuDomainObjEnterMonitorWithDriver(driver, *vm);
+ if (qemuMonitorSystemReset(priv->mon) < 0) {
+ qemuDomainObjExitMonitorWithDriver(driver, *vm);
+ goto endjob;
+ }
+ qemuDomainObjExitMonitorWithDriver(driver, *vm);
+
+ ret = 0;
+
+endjob:
+ if (qemuDomainObjEndJob(driver, *vm) == 0)
+ *vm = NULL;
+cleanup:
+ return ret;
+}
+
static int qemudDomainCoreDump(virDomainPtr dom,
const char *path,
unsigned int flags)
@@ -2870,7 +2911,8 @@ static int qemudDomainCoreDump(virDomainPtr dom,
int ret = -1;
virDomainEventPtr event = NULL;
- virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH | VIR_DUMP_BYPASS_CACHE, -1);
+ virCheckFlags(VIR_DUMP_LIVE | VIR_DUMP_CRASH |
+ VIR_DUMP_BYPASS_CACHE | VIR_DUMP_REBOOT, -1);
qemuDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -2949,11 +2991,17 @@ endjob:
}
cleanup:
- if (vm)
- virDomainObjUnlock(vm);
if (event)
qemuDomainEventQueue(driver, event);
+
+ if ((ret == 0) && (flags & VIR_DUMP_REBOOT) && vm) {
+ ret = doSystemReset(driver, &vm);
+ }
+
+ if (vm)
+ virDomainObjUnlock(vm);
qemuDriverUnlock(driver);
+
return ret;
}
diff --git a/tools/virsh.c b/tools/virsh.c
index e5ea9d7..bdff33c 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -2899,6 +2899,7 @@ static const vshCmdOptDef opts_dump[] = {
{"crash", VSH_OT_BOOL, 0, N_("crash the domain after core dump")},
{"bypass-cache", VSH_OT_BOOL, 0,
N_("avoid file system cache when saving")},
+ {"reboot", VSH_OT_BOOL, 0, N_("reboot the domain after core dump")},
{"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")},
{"file", VSH_OT_DATA, VSH_OFLAG_REQ, N_("where to dump the core")},
{NULL, 0, 0, NULL}
@@ -2928,6 +2929,8 @@ cmdDump(vshControl *ctl, const vshCmd *cmd)
flags |= VIR_DUMP_CRASH;
if (vshCommandOptBool(cmd, "bypass-cache"))
flags |= VIR_DUMP_BYPASS_CACHE;
+ if (vshCommandOptBool(cmd, "reboot"))
+ flags |= VIR_DUMP_REBOOT;
if (virDomainCoreDump(dom, to, flags) < 0) {
vshError(ctl, _("Failed to core dump domain %s to %s"), name, to);
--
1.7.3.4
13 years, 2 months
[libvirt] [PATCH] debug: Annotate some variables as unused
by Michal Privoznik
as they are not used with debugging turned off.
---
daemon/stream.c | 4 +-
src/locking/lock_driver_nop.c | 6 ++--
src/lxc/lxc_container.c | 2 +-
src/lxc/lxc_driver.c | 2 +-
src/node_device/node_device_udev.c | 2 +-
src/qemu/qemu_migration.c | 2 +-
src/rpc/virnettlscontext.c | 5 ++-
src/util/command.c | 9 +++++--
src/util/virpidfile.c | 2 +-
src/vbox/vbox_tmpl.c | 37 +++++++++++++++++++++--------------
10 files changed, 41 insertions(+), 30 deletions(-)
diff --git a/daemon/stream.c b/daemon/stream.c
index e3214c2..7df9952 100644
--- a/daemon/stream.c
+++ b/daemon/stream.c
@@ -94,7 +94,7 @@ daemonStreamUpdateEvents(daemonClientStream *stream)
* fast stream, but slow client
*/
static void
-daemonStreamMessageFinished(virNetMessagePtr msg,
+daemonStreamMessageFinished(virNetMessagePtr msg ATTRIBUTE_UNUSED,
void *opaque)
{
daemonClientStream *stream = opaque;
@@ -244,7 +244,7 @@ cleanup:
* -1 on fatal client error
*/
static int
-daemonStreamFilter(virNetServerClientPtr client,
+daemonStreamFilter(virNetServerClientPtr client ATTRIBUTE_UNUSED,
virNetMessagePtr msg,
void *opaque)
{
diff --git a/src/locking/lock_driver_nop.c b/src/locking/lock_driver_nop.c
index 4f35afa..570b7e7 100644
--- a/src/locking/lock_driver_nop.c
+++ b/src/locking/lock_driver_nop.c
@@ -27,9 +27,9 @@
#include "uuid.h"
-static int virLockManagerNopInit(unsigned int version,
- const char *configFile,
- unsigned int flags)
+static int virLockManagerNopInit(unsigned int version ATTRIBUTE_UNUSED,
+ const char *configFile ATTRIBUTE_UNUSED,
+ unsigned int flags ATTRIBUTE_UNUSED)
{
VIR_DEBUG("version=%u configFile=%s flags=%x",
version, NULLSTR(configFile), flags);
diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c
index 6991aec..787df9a 100644
--- a/src/lxc/lxc_container.c
+++ b/src/lxc/lxc_container.c
@@ -1245,7 +1245,7 @@ int lxcContainerAvailable(int features)
cpid = clone(lxcContainerDummyChild, childStack, flags, NULL);
VIR_FREE(stack);
if (cpid < 0) {
- char ebuf[1024];
+ char ebuf[1024] ATTRIBUTE_UNUSED;
VIR_DEBUG("clone call returned %s, container support is not enabled",
virStrerror(errno, ebuf, sizeof ebuf));
return -1;
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 6cf7203..4b62600 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -2165,7 +2165,7 @@ static int lxcStartup(int privileged)
rc = virCgroupForDriver("lxc", &lxc_driver->cgroup, privileged, 1);
if (rc < 0) {
- char buf[1024];
+ char buf[1024] ATTRIBUTE_UNUSED;
VIR_DEBUG("Unable to create cgroup for LXC driver: %s",
virStrerror(-rc, buf, sizeof(buf)));
/* Don't abort startup. We will explicitly report to
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 08ef856..9112c96 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -703,7 +703,7 @@ out:
}
-static int udevGetSCSIType(virNodeDeviceDefPtr def,
+static int udevGetSCSIType(virNodeDeviceDefPtr def ATTRIBUTE_UNUSED,
unsigned int type, char **typestring)
{
int ret = 0;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 0a5a13d..ef48d65 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1829,7 +1829,7 @@ cleanup:
* instead of client app context & also adding in tunnel
* handling */
static int doPeer2PeerMigrate2(struct qemud_driver *driver,
- virConnectPtr sconn,
+ virConnectPtr sconn ATTRIBUTE_UNUSED,
virConnectPtr dconn,
virDomainObjPtr vm,
const char *dconnuri,
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index e6123f9..971fb80 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -96,7 +96,8 @@ virNetTLSContextCheckCertFile(const char *type, const char *file, bool allowMiss
}
-static void virNetTLSLog(int level, const char *str) {
+static void virNetTLSLog(int level ATTRIBUTE_UNUSED,
+ const char *str ATTRIBUTE_UNUSED) {
VIR_DEBUG("%d %s", level, str);
}
@@ -490,7 +491,7 @@ static int virNetTLSContextCheckCertPair(gnutls_x509_crt_t cert,
static gnutls_x509_crt_t virNetTLSContextLoadCertFromFile(const char *certFile,
bool isServer,
- bool isCA)
+ bool isCA ATTRIBUTE_UNUSED)
{
gnutls_datum_t data;
gnutls_x509_crt_t cert = NULL;
diff --git a/src/util/command.c b/src/util/command.c
index d390478..699ba2d 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -1686,7 +1686,8 @@ virCommandProcessIO(virCommandPtr cmd)
} else {
inoff += done;
if (inoff == inlen) {
- int tmpfd = infd;
+ int tmpfd ATTRIBUTE_UNUSED;
+ tmpfd = infd;
if (VIR_CLOSE(infd) < 0)
VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
}
@@ -1877,7 +1878,8 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
}
if (cmd->outbuf == &outbuf) {
- int tmpfd = cmd->outfd;
+ int tmpfd ATTRIBUTE_UNUSED;
+ tmpfd = cmd->outfd;
if (VIR_CLOSE(cmd->outfd) < 0)
VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
cmd->outfdptr = NULL;
@@ -1885,7 +1887,8 @@ virCommandRun(virCommandPtr cmd, int *exitstatus)
VIR_FREE(outbuf);
}
if (cmd->errbuf == &errbuf) {
- int tmpfd = cmd->errfd;
+ int tmpfd ATTRIBUTE_UNUSED;
+ tmpfd = cmd->errfd;
if (VIR_CLOSE(cmd->errfd) < 0)
VIR_DEBUG("ignoring failed close on fd %d", tmpfd);
cmd->errfdptr = NULL;
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 8206e1a..1fd6318 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -351,7 +351,7 @@ int virPidFileAcquirePath(const char *path,
* one that now exists on the filesystem
*/
if (stat(path, &a) < 0) {
- char ebuf[1024];
+ char ebuf[1024] ATTRIBUTE_UNUSED;
VIR_DEBUG("Pid file '%s' disappeared: %s",
path, virStrerror(errno, ebuf, sizeof ebuf));
VIR_FORCE_CLOSE(fd);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index 0e4364f..b483d0f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -6447,7 +6447,7 @@ cleanup:
/* Functions needed for Callbacks */
static nsresult PR_COM_METHOD
-vboxCallbackOnMachineStateChange(IVirtualBoxCallback *pThis,
+vboxCallbackOnMachineStateChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
PRUnichar *machineId, PRUint32 state)
{
virDomainPtr dom = NULL;
@@ -6521,7 +6521,7 @@ vboxCallbackOnMachineStateChange(IVirtualBoxCallback *pThis,
}
static nsresult PR_COM_METHOD
-vboxCallbackOnMachineDataChange(IVirtualBoxCallback *pThis,
+vboxCallbackOnMachineDataChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
PRUnichar *machineId)
{
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
@@ -6531,11 +6531,11 @@ vboxCallbackOnMachineDataChange(IVirtualBoxCallback *pThis,
}
static nsresult PR_COM_METHOD
-vboxCallbackOnExtraDataCanChange(IVirtualBoxCallback *pThis,
+vboxCallbackOnExtraDataCanChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
PRUnichar *machineId, PRUnichar *key,
PRUnichar *value,
PRUnichar **error ATTRIBUTE_UNUSED,
- PRBool *allowChange)
+ PRBool *allowChange ATTRIBUTE_UNUSED)
{
VIR_DEBUG("IVirtualBoxCallback: %p, allowChange: %s", pThis, *allowChange ? "true" : "false");
DEBUGPRUnichar("machineId", machineId);
@@ -6546,7 +6546,8 @@ vboxCallbackOnExtraDataCanChange(IVirtualBoxCallback *pThis,
}
static nsresult PR_COM_METHOD
-vboxCallbackOnExtraDataChange(IVirtualBoxCallback *pThis, PRUnichar *machineId,
+vboxCallbackOnExtraDataChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
+ PRUnichar *machineId,
PRUnichar *key, PRUnichar *value)
{
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
@@ -6559,8 +6560,10 @@ vboxCallbackOnExtraDataChange(IVirtualBoxCallback *pThis, PRUnichar *machineId,
# if VBOX_API_VERSION < 3001
static nsresult PR_COM_METHOD
-vboxCallbackOnMediaRegistered(IVirtualBoxCallback *pThis, PRUnichar *mediaId,
- PRUint32 mediaType, PRBool registered)
+vboxCallbackOnMediaRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
+ PRUnichar *mediaId,
+ PRUint32 mediaType ATTRIBUTE_UNUSED,
+ PRBool registered ATTRIBUTE_UNUSED)
{
VIR_DEBUG("IVirtualBoxCallback: %p, registered: %s", pThis, registered ? "true" : "false");
VIR_DEBUG("mediaType: %d", mediaType);
@@ -6572,7 +6575,7 @@ vboxCallbackOnMediaRegistered(IVirtualBoxCallback *pThis, PRUnichar *mediaId,
# endif /* VBOX_API_VERSION >= 3001 */
static nsresult PR_COM_METHOD
-vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis,
+vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
PRUnichar *machineId, PRBool registered)
{
virDomainPtr dom = NULL;
@@ -6631,8 +6634,9 @@ vboxCallbackOnMachineRegistered(IVirtualBoxCallback *pThis,
}
static nsresult PR_COM_METHOD
-vboxCallbackOnSessionStateChange(IVirtualBoxCallback *pThis,
- PRUnichar *machineId, PRUint32 state)
+vboxCallbackOnSessionStateChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
+ PRUnichar *machineId,
+ PRUint32 state ATTRIBUTE_UNUSED)
{
VIR_DEBUG("IVirtualBoxCallback: %p, state: %d", pThis, state);
DEBUGPRUnichar("machineId", machineId);
@@ -6641,7 +6645,8 @@ vboxCallbackOnSessionStateChange(IVirtualBoxCallback *pThis,
}
static nsresult PR_COM_METHOD
-vboxCallbackOnSnapshotTaken(IVirtualBoxCallback *pThis, PRUnichar *machineId,
+vboxCallbackOnSnapshotTaken(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
+ PRUnichar *machineId,
PRUnichar *snapshotId)
{
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
@@ -6652,7 +6657,8 @@ vboxCallbackOnSnapshotTaken(IVirtualBoxCallback *pThis, PRUnichar *machineId,
}
static nsresult PR_COM_METHOD
-vboxCallbackOnSnapshotDiscarded(IVirtualBoxCallback *pThis, PRUnichar *machineId,
+vboxCallbackOnSnapshotDiscarded(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
+ PRUnichar *machineId,
PRUnichar *snapshotId)
{
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
@@ -6663,7 +6669,8 @@ vboxCallbackOnSnapshotDiscarded(IVirtualBoxCallback *pThis, PRUnichar *machineId
}
static nsresult PR_COM_METHOD
-vboxCallbackOnSnapshotChange(IVirtualBoxCallback *pThis, PRUnichar *machineId,
+vboxCallbackOnSnapshotChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
+ PRUnichar *machineId,
PRUnichar *snapshotId)
{
VIR_DEBUG("IVirtualBoxCallback: %p", pThis);
@@ -6674,7 +6681,7 @@ vboxCallbackOnSnapshotChange(IVirtualBoxCallback *pThis, PRUnichar *machineId,
}
static nsresult PR_COM_METHOD
-vboxCallbackOnGuestPropertyChange(IVirtualBoxCallback *pThis,
+vboxCallbackOnGuestPropertyChange(IVirtualBoxCallback *pThis ATTRIBUTE_UNUSED,
PRUnichar *machineId, PRUnichar *name,
PRUnichar *value, PRUnichar *flags)
{
@@ -6688,7 +6695,7 @@ vboxCallbackOnGuestPropertyChange(IVirtualBoxCallback *pThis,
}
static nsresult PR_COM_METHOD
-vboxCallbackAddRef(nsISupports *pThis)
+vboxCallbackAddRef(nsISupports *pThis ATTRIBUTE_UNUSED)
{
nsresult c;
--
1.7.3.4
13 years, 2 months
[libvirt] [test-API][PATCH] Add a case for testing update device flag
by Nan Zhang
---
repos/domain/update_devflag.py | 159 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 159 insertions(+), 0 deletions(-)
create mode 100644 repos/domain/update_devflag.py
diff --git a/repos/domain/update_devflag.py b/repos/domain/update_devflag.py
new file mode 100644
index 0000000..b2d8d15
--- /dev/null
+++ b/repos/domain/update_devflag.py
@@ -0,0 +1,159 @@
+#!/usr/bin/evn python
+"""Update virtual device to guest from an XML file
+"""
+
+__author__ = 'Nan Zhang: nzhang(a)redhat.com'
+__date__ = 'Fri Sep 2, 2011'
+__version__ = '0.1.0'
+__credits__ = 'Copyright (C) 2011 Red Hat, Inc.'
+__all__ = ['usage', 'update_devflag']
+
+import os
+import re
+import sys
+import time
+from xml.dom import minidom
+
+def append_path(path):
+ """Append root path of package"""
+ if path in sys.path:
+ pass
+ else:
+ sys.path.append(path)
+
+pwd = os.getcwd()
+result = re.search('(.*)libvirt-test-API', pwd)
+append_path(result.group(0))
+
+from lib import connectAPI
+from lib import domainAPI
+from utils.Python import utils
+from utils.Python import xmlbuilder
+from exception import LibvirtAPI
+from repos import domain
+
+def usage():
+ print '''usage: mandatory arguments:
+ guestname
+ devtype
+ flag
+ '''
+
+def check_params(params):
+ """Verify inputing parameter dictionary"""
+ logger = params['logger']
+ keys = ['guestname', 'devtype', 'flag']
+ for key in keys:
+ if key not in params:
+ logger.error("%s is required" %key)
+ usage()
+ return 1
+ return 0
+
+def create_image(img_name, img_size, logger):
+ """Create an image file"""
+ stat, ret = commands.getstatusoutput("dd if=/dev/zero of=%s bs=1 \
+ count=1 seek=%s" % (img_name, img_size))
+ if stat == 0:
+ logger.debug("create image result:\n%s" % ret)
+ return True
+ else:
+ return False
+
+def check_updated_device(guestname, domobj, srcfile):
+ """Check if the device is updated"""
+ xmlobj = domobj.get_xml_desc(guestname)
+ domxml = minidom.parseString(xmlobj)
+
+ for diskTag in domxml.getElementsByTagName("source"):
+ if diskTag.parentNode.getAttribute("device") == 'cdrom':
+ upfile = diskTag.getAttribute("file")
+ elif diskTag.parentNode.getAttribute('device') == 'floppy':
+ upfile = diskTag.getAttribute("file")
+ else:
+ logger.error("No matched device was found.")
+
+ if upfile == srcfile:
+ return True, upfile
+ else:
+ return False, upfile
+
+def update_devflag(params):
+ """Update virtual device to a domain from xml"""
+
+ # Initiate and check parameters
+ params_check_result = check_params(params)
+ if params_check_result:
+ return 1
+ logger = params['logger']
+ guestname = params['guestname']
+ devtype = params['devtype']
+ if devtype == 'cdrom':
+ xmlargs = {}
+ xmlargs['guesttype'] = 'kvm'
+ xmlargs['hdmodel'] = 'ide'
+ xmlargs['bootcd'] = '/var/lib/libvirt/boot/cdrom.img'
+ srcfile = xmlargs['bootcd']
+ create_image(srcfile, 100M, logger)
+ elif devtype = 'floppy':
+ xmlargs = {}
+ xmlargs['floppysource'] = '/var/lib/libvirt/boot/floppy.img'
+ srcfile = xmlargs['floppysource']
+ create_image(srcfile, 2M, logger)
+ else:
+ logger.error("Wrong device type was specified.")
+ return 1
+
+ if not params.has_key('flag'):
+ flag = VIR_DOMAIN_AFFECT_CONFIG
+
+ # Connect to local hypervisor connection URI
+ util = utils.Utils()
+ uri = util.get_uri('127.0.0.1')
+ conn = connectAPI.ConnectAPI()
+ virconn = conn.open(uri)
+
+ caps = conn.get_caps()
+ logger.debug(caps)
+
+ # Generate device XML for updating
+ domobj = domainAPI.DomainAPI(virconn)
+ newxmlobj = xmlbuilder.XmlBuilder()
+
+ if devtype == 'cdrom':
+ newdevxml = newxmlobj.build_cdrom(xmlargs)
+ elif devtype == 'floppy':
+ newdevxml = newxmlobj.build_floppy(xmlargs)
+
+ logger.debug("block device xml desc:\n%s" %newdevxml)
+
+ try:
+ try:
+ domobj.update_device_flag(guestname, newdevxml, flag)
+ res, upfile = check_updated_device(guestname, domobj, srcfile)
+ if res:
+ logger.info("success to update '%s' device: %s\n" % \
+ devtype, upfile)
+ else:
+ logger.error("fail to update '%s' device: %s\n" % \
+ devtype, upfile)
+ except LibvirtAPI, e:
+ logger.error("API error message: %s, error code is %s" %
+ (e.response()['message'], e.response()['code']))
+ conn.close()
+ logger.info("closed hypervisor connection")
+ return 1
+ finally:
+ conn.close()
+ logger.info("closed hypervisor connection")
+
+ return 0
+
+def update_devflag_clean(params):
+ """Clean testing environment"""
+ if params['devtype'] == 'cdrom':
+ os.system('rm -f /var/lib/libvirt/boot/cdrom.img')
+ elif params['devtype'] == 'floppy':
+ os.system('rm -f /var/lib/libvirt/boot/floppy.img')
+ else:
+ logger.debug("image file was not found.")
--
1.7.4.4
13 years, 2 months
[libvirt] [PATCH] qemu: add return value check
by ajia@redhat.com
From: Alex Jia <ajia(a)redhat.com>
* src/qemu/qemu_migration.c: if 'vmdef' is NULL, the function
virDomainSaveConfig still dereferences it, it doesn't make
sense, so should add return value check to make sure 'vmdef'
is non-NULL before calling virDomainSaveConfig.
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/qemu/qemu_migration.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 0a5a13d..ec994a5 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -2580,8 +2580,14 @@ qemuMigrationFinish(struct qemud_driver *driver,
vm->persistent = 1;
if (mig->persistent)
vm->newDef = vmdef = mig->persistent;
- else
+ else {
vmdef = virDomainObjGetPersistentDef(driver->caps, vm);
+ if (!vmdef) {
+ qemuReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("can't get vmdef"));
+ goto endjob;
+ }
+ }
if (virDomainSaveConfig(driver->configDir, vmdef) < 0) {
/* Hmpf. Migration was successful, but making it persistent
* was not. If we report successful, then when this domain
--
1.7.1
13 years, 2 months
[libvirt] [PATCH v2] storage: Do not break the whole vol lookup process in the middle
by Osier Yang
* src/storage/storage_driver.c: As virStorageVolLookupByPath lookups
all the pool objs of the drivers, breaking when failing on getting
the stable path of the pool will just breaks the whole lookup process,
it can cause the API fails even if the vol exists indeed. It won't get
any benefit. This patch is to fix it.
---
src/storage/storage_driver.c | 13 ++++++-------
1 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index c05b74e..8c2d6e1 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -1247,14 +1247,14 @@ storageVolumeLookupByPath(virConnectPtr conn,
stable_path = virStorageBackendStablePath(driver->pools.objs[i],
cleanpath);
- /*
- * virStorageBackendStablePath already does
- * virStorageReportError if it fails; we just need to keep
- * propagating the return code
- */
if (stable_path == NULL) {
+ /* Don't break the whole lookup process if it fails on
+ * getting the stable path for some of the pools.
+ */
+ VIR_WARN("Failed to get stable path for pool '%s'",
+ driver->pools.objs[i]->def->name);
virStoragePoolObjUnlock(driver->pools.objs[i]);
- goto cleanup;
+ continue;
}
vol = virStorageVolDefFindByPath(driver->pools.objs[i],
@@ -1274,7 +1274,6 @@ storageVolumeLookupByPath(virConnectPtr conn,
virStorageReportError(VIR_ERR_NO_STORAGE_VOL,
"%s", _("no storage vol with matching path"));
-cleanup:
VIR_FREE(cleanpath);
storageDriverUnlock(driver);
return ret;
--
1.7.6
13 years, 2 months