[libvirt] Segfault in libvirt with lxc driver
by Thomas Hunger
Hi,
I am running libvirt 0.10 on debian [1] and I am getting the following
segfault [2] about once a day when using the lxc driver. I don't know
how to reproduce the circumstances unfortunately. It seems to happen
when destroying domains. I attached the debug log leading up to the
segfault. Is this useful? Do you need more information?
best, Tom
[1]
$ uname -a
Linux zap 3.1.0-1-amd64 #1 SMP Tue Jan 10 05:01:58 UTC 2012 x86_64 GNU/Linux
[2]
Program received signal SIGSEGV, Segmentation fault.
lxcMonitorEvent (watch=43, fd=23, events=<value optimized out>, data=0x82ffa0)
at /tmp/buildd/libvirt-0.9.10/./src/lxc/lxc_driver.c:1512
1512 /tmp/buildd/libvirt-0.9.10/./src/lxc/lxc_driver.c: No such file
or directory.
in /tmp/buildd/libvirt-0.9.10/./src/lxc/lxc_driver.c
(gdb) bt
#0 lxcMonitorEvent (watch=43, fd=23, events=<value optimized out>,
data=0x82ffa0)
at /tmp/buildd/libvirt-0.9.10/./src/lxc/lxc_driver.c:1512
#1 0x00007ffff77c48b2 in virEventPollDispatchHandles () at
/tmp/buildd/libvirt-0.9.10/./src/util/event_poll.c:490
#2 virEventPollRunOnce () at
/tmp/buildd/libvirt-0.9.10/./src/util/event_poll.c:637
#3 0x00007ffff77c32f7 in virEventRunDefaultImpl () at
/tmp/buildd/libvirt-0.9.10/./src/util/event.c:247
#4 0x00007ffff788dffd in virNetServerRun (srv=0x76a410) at
/tmp/buildd/libvirt-0.9.10/./src/rpc/virnetserver.c:735
#5 0x0000000000423430 in main (argc=<value optimized out>,
argv=<value optimized out>)
at /tmp/buildd/libvirt-0.9.10/./daemon/libvirtd.c:1602
12 years, 8 months
[libvirt] [PATCH 0/9] Add supports for three new QMP events
by Osier Yang
This patch series adds support for 3 new QMP events: WAKEUP,
SUSPEND, and DEVICE_TRAY_MOVED, and related changes on domain's
conf and status.
[1/9]
Add support for tray moved event
[2/9] ~ [5/9]:
New attribute "tray" is added to disk target, it indicates
the tray status of removable disk, i.e. CDROM and Floppy disks,
its value could be either of "open" or "closed", defaults to
"closed", and a removable disk with tray == "open" won't have
the source when domain is started. The value of "tray" will
be updated while tray moved event is emitted from guest.
Prior to these patches, if the user ejected the medium of
removable disk from guest side, and then do migration or
save/restoring, the guest will still starts the medium source
,and thus the medium will still exists in guest, which is
strange. These patches fix it.
[6/9] + [8/9]:
Add support for wakeup event, and update the domain status
to paused if the domain is running, while the wakeup event is
emitted.
[7/9] + [9/9]:
Add support for suspend event, and update the domain status
to running if the domain was paused by suspend event, while the
suspend event is emitted.
Osier Yang(9)
Add support for event tray moved of removable disks
docs: Add documentation for new attribute tray of disk target
conf: Parse and for the tray attribute
qemu: Do not start with source for removable disks if tray is open
qemu: Update tray status while tray moved event is emitted
Add support for the wakeup event
Add support for the event suspend
qemu: Update domain status to paused while suspend event is emitted
qemu: Update domain status to running while wakeup event is emitted
daemon/remote.c | 80 +++++++++++
docs/formatdomain.html.in | 13 ++-
docs/schemas/domaincommon.rng | 8 +
examples/domain-events/events-c/event-test.c | 61 ++++++++-
examples/domain-events/events-python/event-test.py | 12 ++
include/libvirt/libvirt.h.in | 56 ++++++++
python/libvirt-override-virConnect.py | 27 ++++
python/libvirt-override.c | 146 ++++++++++++++++++++
src/conf/domain_conf.c | 33 +++++-
src/conf/domain_conf.h | 9 ++
src/conf/domain_event.c | 117 ++++++++++++++++
src/conf/domain_event.h | 10 ++
src/libvirt_private.syms | 6 +
src/qemu/qemu_command.c | 16 ++-
src/qemu/qemu_monitor.c | 37 +++++
src/qemu/qemu_monitor.h | 14 ++
src/qemu/qemu_monitor_json.c | 37 +++++-
src/qemu/qemu_process.c | 131 ++++++++++++++++++
src/remote/remote_driver.c | 98 +++++++++++++
src/remote/remote_protocol.x | 19 +++-
src/remote_protocol-structs | 11 ++
tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.xml | 2 +-
.../qemuxml2argv-boot-complex-bootindex.xml | 6 +-
.../qemuxml2argvdata/qemuxml2argv-boot-complex.xml | 6 +-
.../qemuxml2argvdata/qemuxml2argv-boot-floppy.xml | 2 +-
...uxml2argv-boot-menu-disable-drive-bootindex.xml | 2 +-
.../qemuxml2argv-boot-menu-disable-drive.xml | 2 +-
.../qemuxml2argv-boot-menu-disable.xml | 2 +-
.../qemuxml2argv-boot-menu-enable.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-boot-multi.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-boot-order.xml | 4 +-
tests/qemuxml2argvdata/qemuxml2argv-bootloader.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-disk-aio.xml | 2 +-
.../qemuxml2argv-disk-cdrom-empty.xml | 2 +-
...qemuxml2argv-disk-cdrom-tray-no-device-cap.args | 4 +
.../qemuxml2argv-disk-cdrom-tray-no-device-cap.xml | 32 +++++
.../qemuxml2argv-disk-cdrom-tray.args | 10 ++
.../qemuxml2argv-disk-cdrom-tray.xml | 43 ++++++
tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.xml | 2 +-
.../qemuxml2argv-disk-copy_on_read.xml | 2 +-
.../qemuxml2argv-disk-drive-boot-cdrom.xml | 2 +-
.../qemuxml2argv-disk-drive-boot-disk.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-directsync.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-unsafe.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-v1-none.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-v1-wb.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-v1-wt.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-v2-none.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-v2-wb.xml | 2 +-
.../qemuxml2argv-disk-drive-cache-v2-wt.xml | 2 +-
...muxml2argv-disk-drive-error-policy-enospace.xml | 2 +-
.../qemuxml2argv-disk-drive-error-policy-stop.xml | 2 +-
...rgv-disk-drive-error-policy-wreport-rignore.xml | 2 +-
.../qemuxml2argv-disk-drive-fmt-qcow.xml | 2 +-
.../qemuxml2argv-disk-drive-no-boot.xml | 4 +-
.../qemuxml2argv-disk-drive-readonly-disk.xml | 2 +-
.../qemuxml2argv-disk-drive-readonly-no-device.xml | 2 +-
.../qemuxml2argv-disk-drive-shared.xml | 2 +-
...emuxml2argv-disk-floppy-tray-no-device-cap.args | 4 +
...qemuxml2argv-disk-floppy-tray-no-device-cap.xml | 37 +++++
.../qemuxml2argv-disk-floppy-tray.args | 10 ++
.../qemuxml2argv-disk-floppy-tray.xml | 37 +++++
.../qemuxml2argvdata/qemuxml2argv-disk-floppy.xml | 4 +-
.../qemuxml2argv-disk-ioeventfd.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-disk-order.xml | 2 +-
.../qemuxml2argv-disk-snapshot.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-disk-virtio.xml | 2 +-
.../qemuxml2argvdata/qemuxml2argv-disk-xenvbd.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-event_idx.xml | 2 +-
.../qemuxml2argv-floppy-drive-fat.xml | 2 +-
.../qemuxml2argv-graphics-spice-timeout.xml | 2 +-
tests/qemuxml2argvdata/qemuxml2argv-lease.xml | 2 +-
.../qemuxml2argv-net-bandwidth.xml | 2 +-
tests/qemuxml2argvtest.c | 6 +
.../qemuxml2xmlout-graphics-spice-timeout.xml | 2 +-
tests/vmx2xmldata/vmx2xml-cdrom-ide-device.xml | 2 +-
tests/vmx2xmldata/vmx2xml-cdrom-ide-file.xml | 2 +-
tests/vmx2xmldata/vmx2xml-cdrom-scsi-device.xml | 2 +-
tests/vmx2xmldata/vmx2xml-cdrom-scsi-file.xml | 2 +-
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-2.xml | 8 +-
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-3.xml | 4 +-
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-5.xml | 2 +-
tests/vmx2xmldata/vmx2xml-esx-in-the-wild-6.xml | 2 +-
tests/vmx2xmldata/vmx2xml-floppy-device.xml | 2 +-
tests/vmx2xmldata/vmx2xml-floppy-file.xml | 2 +-
tests/vmx2xmldata/vmx2xml-ws-in-the-wild-1.xml | 2 +-
tests/vmx2xmldata/vmx2xml-ws-in-the-wild-2.xml | 2 +-
tools/virsh.c | 4 +
88 files changed, 1185 insertions(+), 79 deletions(-)
Regards,
Osier
12 years, 8 months
[libvirt] [PATCH][TCK] add tests for network interface transaction
by Xiaoqiang Hu
add tests for network interface transaction: interface_change_begin,
interface_change_commit and interface_change_rollback
---
.../networks/110-interface-change-transaction.t | 81 ++++++++++++++++++++
1 files changed, 81 insertions(+), 0 deletions(-)
create mode 100644 scripts/networks/110-interface-change-transaction.t
diff --git a/scripts/networks/110-interface-change-transaction.t b/scripts/networks/110-interface-change-transaction.t
new file mode 100644
index 0000000..f518d9f
--- /dev/null
+++ b/scripts/networks/110-interface-change-transaction.t
@@ -0,0 +1,81 @@
+# -*- perl -*-
+#
+# Copyright (C) 2012-2013 Red Hat, Inc.
+# Copyright (C) 2012-2013 Xiaoqiang Hu <xhu(a)redhat.com>
+#
+# This program is free software; You can redistribute it and/or modify
+# it under the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any
+# later version
+#
+# The file "LICENSE" distributed along with this file provides full
+# details of the terms and conditions
+#
+
+=pod
+
+=head1 NAME
+
+networks/110-interface-lifecycle.t: test transaction for changing the
+configuration of one or more network interfaces
+
+=head1 DESCRIPTION
+
+The test case validates the transaction for changing the configuration
+of one or more network interfaces
+
+=cut
+
+use strict;
+use warnings;
+
+use Test::More tests => 2;
+
+use Sys::Virt::TCK;
+use Test::Exception;
+
+my $network_script_dir = "/etc/sysconfig/network-scripts";
+my $test_interface_name = "ifcfg-interface-tck-test";
+my $test_interface_cfg = $network_script_dir."/".$test_interface_name;
+my $tck = Sys::Virt::TCK->new();
+my $conn = eval { $tck->setup(); };
+BAIL_OUT "failed to setup test harness: $@" if $@;
+END {
+ $tck->cleanup if $tck;
+ unlink $test_interface_cfg if -f $test_interface_cfg;
+}
+
+my $ret;
+
+unlink $test_interface_cfg if -f $test_interface_cfg;
+
+eval { $conn->interface_change_begin(); };
+SKIP: {
+ skip "interface_change_begin/commit/rollback not implemented", 2 if $@ && err_not_implemented($@);
+
+ $ret = system("cat <<EOF > $test_interface_cfg
+DEVICE=\"interface-tck-test\"
+BOOTPROTO=\"none\"
+ONBOOT=\"no\"
+EOF
+");
+
+ $conn->interface_change_rollback();
+ ok(! -e $test_interface_cfg, "interface rollback");
+
+ unlink $test_interface_cfg if -f $test_interface_cfg;
+
+ $conn->interface_change_begin();
+
+ $ret = system("cat <<EOF > $test_interface_cfg
+DEVICE=\"interface-tck-test\"
+BOOTPROTO=\"none\"
+ONBOOT=\"no\"
+EOF
+");
+
+ $conn->interface_change_commit();
+ ok(-e $test_interface_cfg, "interface commit");
+}
+
+# end
--
1.7.1
12 years, 8 months
[libvirt] [PATCH v2] apparmor: QEMU bridge helper policy updates
by Corey Bryant
This patch provides AppArmor policy updates for the QEMU bridge helper.
The QEMU bridge helper is a SUID executable exec'd by QEMU that drops
capabilities to CAP_NET_ADMIN and adds a tap device to a network
bridge. For more details on the helper, please refer to:
http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg03562.html
Signed-off-by: Corey Bryant <coreyb(a)linux.vnet.ibm.com>
---
examples/apparmor/libvirt-qemu | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/examples/apparmor/libvirt-qemu b/examples/apparmor/libvirt-qemu
index 10cdd36..c5a11b6 100644
--- a/examples/apparmor/libvirt-qemu
+++ b/examples/apparmor/libvirt-qemu
@@ -1,4 +1,4 @@
-# Last Modified: Mon Apr 5 15:11:27 2010
+# Last Modified: Fri Mar 9 14:43:22 2012
#include <abstractions/base>
#include <abstractions/consoles>
@@ -108,3 +108,23 @@
/bin/dash rmix,
/bin/dd rmix,
/bin/cat rmix,
+
+ /usr/libexec/qemu-bridge-helper Cx,
+
+ # child profile for bridge helper process
+ profile /usr/libexec/qemu-bridge-helper {
+ #include <abstractions/base>
+
+ capability setuid,
+ capability setgid,
+ capability setpcap,
+ capability net_admin,
+
+ network inet stream,
+
+ /dev/net/tun rw,
+ /etc/qemu/** r,
+ owner @{PROC}/*/status r,
+
+ /usr/libexec/qemu-bridge-helper rmix,
+ }
--
1.7.7
12 years, 8 months
[libvirt] [PATCH] qemu: Copy console definition from serial
by Michal Privoznik
Now, when we support multiple consoles per domain,
the vm->def->console[0] can still remain an alias
for vm->def->serial[0]; However, we need to copy
it's source definition as well otherwise we'll regress
on virDomainOpenConsole.
---
src/conf/domain_conf.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++
src/conf/domain_conf.h | 2 +
src/libvirt_private.syms | 1 +
src/qemu/qemu_process.c | 19 +++++++++--
4 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 6b78d97..9b2eb86 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -956,6 +956,78 @@ virDomainChrSourceDefClear(virDomainChrSourceDefPtr def)
}
}
+int
+virDomainChrSourceDefCopy(virDomainChrSourceDefPtr dest,
+ virDomainChrSourceDefPtr src)
+{
+ if (!dest || !src)
+ return -1;
+
+ switch (src->type) {
+ case VIR_DOMAIN_CHR_TYPE_PTY:
+ case VIR_DOMAIN_CHR_TYPE_DEV:
+ case VIR_DOMAIN_CHR_TYPE_FILE:
+ case VIR_DOMAIN_CHR_TYPE_PIPE:
+ if (src->data.file.path &&
+ !(dest->data.file.path = strdup(src->data.file.path))) {
+ virReportOOMError();
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_UDP:
+ if (src->data.udp.bindHost &&
+ !(dest->data.udp.bindHost = strdup(src->data.udp.bindHost))) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (src->data.udp.bindService &&
+ !(dest->data.udp.bindService = strdup(src->data.udp.bindService))) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (src->data.udp.connectHost &&
+ !(dest->data.udp.connectHost = strdup(src->data.udp.connectHost))) {
+ virReportOOMError();
+ return -1;
+ }
+
+
+ if (src->data.udp.connectService &&
+ !(dest->data.udp.connectService = strdup(src->data.udp.connectService))) {
+ virReportOOMError();
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_TCP:
+ if (src->data.tcp.host &&
+ !(dest->data.tcp.host = strdup(src->data.tcp.host))) {
+ virReportOOMError();
+ return -1;
+ }
+
+ if (src->data.tcp.service &&
+ !(dest->data.tcp.service = strdup(src->data.tcp.service))) {
+ virReportOOMError();
+ return -1;
+ }
+ break;
+
+ case VIR_DOMAIN_CHR_TYPE_UNIX:
+ if (src->data.nix.path &&
+ !(dest->data.nix.path = strdup(src->data.nix.path))) {
+ virReportOOMError();
+ return -1;
+ }
+ break;
+ }
+
+ return 0;
+}
+
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def)
{
if (!def)
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index c360674..76a8dd7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -1662,6 +1662,8 @@ void virDomainNetDefFree(virDomainNetDefPtr def);
void virDomainSmartcardDefFree(virDomainSmartcardDefPtr def);
void virDomainChrDefFree(virDomainChrDefPtr def);
void virDomainChrSourceDefFree(virDomainChrSourceDefPtr def);
+int virDomainChrSourceDefCopy(virDomainChrSourceDefPtr src,
+ virDomainChrSourceDefPtr dest);
void virDomainSoundDefFree(virDomainSoundDefPtr def);
void virDomainMemballoonDefFree(virDomainMemballoonDefPtr def);
void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index b9d537e..e6ccf9d 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -242,6 +242,7 @@ virDomainChrConsoleTargetTypeToString;
virDomainChrDefForeach;
virDomainChrDefFree;
virDomainChrDefNew;
+virDomainChrSourceDefCopy;
virDomainChrSourceDefFree;
virDomainChrSpicevmcTypeFromString;
virDomainChrSpicevmcTypeToString;
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index 2882ef8..e0b1824 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1163,11 +1163,22 @@ qemuProcessFindCharDevicePTYs(virDomainObjPtr vm,
for (i = 0 ; i < vm->def->nconsoles ; i++) {
virDomainChrDefPtr chr = vm->def->consoles[i];
- if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY &&
- chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
- if ((ret = qemuProcessExtractTTYPath(output, &offset,
- &chr->source.data.file.path)) != 0)
+ /* For historical reasons, console[0] can be just an alias
+ * for serial[0]; That's why we need to update it as well */
+ if (i == 0 && vm->def->nserials &&
+ chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+ chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) {
+ if ((ret = virDomainChrSourceDefCopy(&chr->source,
+ &((vm->def->serials[0])->source))) != 0)
return ret;
+ chr->source.type = VIR_DOMAIN_CHR_TYPE_PTY;
+ } else {
+ if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY &&
+ chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO) {
+ if ((ret = qemuProcessExtractTTYPath(output, &offset,
+ &chr->source.data.file.path)) != 0)
+ return ret;
+ }
}
}
--
1.7.3.4
12 years, 8 months
[libvirt] [PATCH 0/4] Introduce jobs for storage driver
by Michal Privoznik
Disk operations can take ages to finish. Therefore users
might want to abort such job, e.g. because host is going
down for maintenance. This patch set is trying to allow
this kind of behaviour. The inspiration was taken from
qemu driver.
How it works:
An API that is known to run for a long time, e.g. volume
allocation, wiping, have to find a pool which volume
belongs to. If the pool was found it is locked. During
this time the storage driver is locked. Now the API is
preparing for taking the operation. Ideally, it would be
sufficient to have only volume locked, but it requires
far more changes to code.
Just before the API is about to take the long term action,
storageBeginJob[WithPool] is called. This wait on a condition
specific for a volume. Similar to QEMU driver, wait is
limited in time. Timeout is set to 30 seconds.
Upon successful job acquire, a counter in the pool
is incremented so the pool is prevented from destroy,
undef; Then the pool is unlocked.
After API finishes it's work, it calls storageEndJob[WithPool]
which reset job structure in the volume, re-locks
the pool, decrement the counter and broadcasts on
the condition.
Meanwhile, if the long term action is done internally,
it should be done in a cycle so we can check if job abort
wasn't signalized. If it is done by external program,
we can virCommandAbort() it.
Several improvements can be made, but I think this is
good for start.
NB, I've implemented job aborting for the both APIs using
streams, however wasn't very successful with aborting
a stream from the daemon site.
Michal Privoznik (4):
storage: Introduce virStorageVolAbortJob
virsh: Expose virStorageVolAbortJob
storage: Implement jobs for storage driver
storage: Implement virStorageVolAbortJob
include/libvirt/libvirt.h.in | 3 +
src/conf/storage_conf.c | 12 ++
src/conf/storage_conf.h | 29 +++-
src/driver.h | 5 +
src/libvirt.c | 49 +++++
src/libvirt_private.syms | 4 +
src/libvirt_public.syms | 1 +
src/remote/remote_driver.c | 1 +
src/remote/remote_protocol.x | 8 +-
src/remote_protocol-structs | 5 +
src/storage/storage_backend.c | 53 +++---
src/storage/storage_backend_fs.c | 8 +-
src/storage/storage_driver.c | 408 ++++++++++++++++++++++++++++++--------
src/storage/storage_driver.h | 7 +
tools/virsh.c | 39 ++++
15 files changed, 516 insertions(+), 116 deletions(-)
--
1.7.8.5
12 years, 8 months
[libvirt] [PATCH] vmware: detect when a domain was shut down from the inside
by Jean-Baptiste Rouault
This patch adds an internal function vmwareGetVMStatus to
get the real state of the domain. This function is used in
various places in the driver, in particular to detect when
the domain has been shut down by the user with the "halt"
command.
---
src/vmware/vmware_driver.c | 83 +++++++++++++++++++++++++++++++++++++-------
1 files changed, 70 insertions(+), 13 deletions(-)
diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c
index 56e9d2d..6f75f86 100644
--- a/src/vmware/vmware_driver.c
+++ b/src/vmware/vmware_driver.c
@@ -28,6 +28,7 @@
#include "datatypes.h"
#include "virfile.h"
#include "memory.h"
+#include "util.h"
#include "uuid.h"
#include "command.h"
#include "vmx.h"
@@ -181,6 +182,50 @@ vmwareGetVersion(virConnectPtr conn, unsigned long *version)
}
static int
+vmwareGetVMStatus(struct vmware_driver *driver,
+ virDomainObjPtr vm,
+ int *status,
+ int *reason)
+{
+ virCommandPtr cmd;
+ char *outbuf;
+ char *vmxAbsolutePath;
+ int state;
+ int ret = -1;
+
+ cmd = virCommandNewArgList(VMRUN, "-T", vmw_types[driver->type],
+ "list", NULL);
+ virCommandSetOutputBuffer(cmd, &outbuf);
+ if (virCommandRun(cmd, NULL) < 0)
+ goto cleanup;
+
+ state = virDomainObjGetState(vm, reason);
+
+ if (virFileResolveAllLinks(((vmwareDomainPtr) vm->privateData)->vmxPath,
+ &vmxAbsolutePath) == -1)
+ goto cleanup;
+
+ if (strstr(outbuf, vmxAbsolutePath)) {
+ /* If the vmx path is in the output, the domain is running or
+ * is paused but we have no way to detect if it is paused or not. */
+ if (state == VIR_DOMAIN_PAUSED)
+ *status = state;
+ else
+ *status = VIR_DOMAIN_RUNNING;
+ } else {
+ *status = VIR_DOMAIN_SHUTOFF;
+ }
+
+ ret = 0;
+
+cleanup:
+ virCommandFree(cmd);
+ VIR_FREE(outbuf);
+ VIR_FREE(vmxAbsolutePath);
+ return ret;
+}
+
+static int
vmwareStopVM(struct vmware_driver *driver,
virDomainObjPtr vm,
virDomainShutoffReason reason)
@@ -212,12 +257,6 @@ vmwareStartVM(struct vmware_driver *driver, virDomainObjPtr vm)
};
const char *vmxPath = ((vmwareDomainPtr) vm->privateData)->vmxPath;
- if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_SHUTOFF) {
- vmwareError(VIR_ERR_OPERATION_INVALID, "%s",
- _("domain is not in shutoff state"));
- return -1;
- }
-
vmwareSetSentinal(cmd, vmw_types[driver->type]);
vmwareSetSentinal(cmd, vmxPath);
if (!((vmwareDomainPtr) vm->privateData)->gui)
@@ -317,6 +356,7 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
{
struct vmware_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
+ int status;
int ret = -1;
virCheckFlags(0, -1);
@@ -331,7 +371,10 @@ vmwareDomainShutdownFlags(virDomainPtr dom,
goto cleanup;
}
- if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
+ if (vmwareGetVMStatus(driver, vm, &status, NULL) == -1)
+ goto cleanup;
+
+ if (status != VIR_DOMAIN_RUNNING) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
@@ -467,6 +510,7 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
VMRUN, "-T", PROGRAM_SENTINAL,
"reset", PROGRAM_SENTINAL, "soft", NULL
};
+ int status;
int ret = -1;
virCheckFlags(0, -1);
@@ -485,8 +529,10 @@ vmwareDomainReboot(virDomainPtr dom, unsigned int flags)
vmwareSetSentinal(cmd, vmw_types[driver->type]);
vmwareSetSentinal(cmd, vmxPath);
+ if (vmwareGetVMStatus(driver, vm, &status, NULL) == -1)
+ goto cleanup;
- if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_RUNNING) {
+ if (status != VIR_DOMAIN_RUNNING) {
vmwareError(VIR_ERR_INTERNAL_ERROR, "%s",
_("domain is not in running state"));
goto cleanup;
@@ -582,6 +628,7 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
{
struct vmware_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
+ int status;
int ret = -1;
virCheckFlags(0, -1);
@@ -596,7 +643,10 @@ vmwareDomainCreateWithFlags(virDomainPtr dom,
goto cleanup;
}
- if (virDomainObjIsActive(vm)) {
+ if (vmwareGetVMStatus(driver, vm, &status, NULL) == -1)
+ goto cleanup;
+
+ if (status != VIR_DOMAIN_SHUTOFF) {
vmwareError(VIR_ERR_OPERATION_INVALID,
"%s", _("Domain is already running"));
goto cleanup;
@@ -623,6 +673,7 @@ vmwareDomainUndefineFlags(virDomainPtr dom,
{
struct vmware_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
+ int status;
int ret = -1;
virCheckFlags(0, -1);
@@ -645,7 +696,10 @@ vmwareDomainUndefineFlags(virDomainPtr dom,
goto cleanup;
}
- if (virDomainObjIsActive(vm)) {
+ if (vmwareGetVMStatus(driver, vm, &status, NULL) == -1)
+ goto cleanup;
+
+ if (status == VIR_DOMAIN_RUNNING) {
vm->persistent = 0;
} else {
virDomainRemoveInactive(&driver->domains, vm);
@@ -902,6 +956,7 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
{
struct vmware_driver *driver = dom->conn->privateData;
virDomainObjPtr vm;
+ int state;
int ret = -1;
vmwareDriverLock(driver);
@@ -914,7 +969,10 @@ vmwareDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info)
goto cleanup;
}
- info->state = virDomainObjGetState(vm, NULL);
+ if (vmwareGetVMStatus(driver, vm, &state, NULL) == -1)
+ goto cleanup;
+
+ info->state = state;
info->cpuTime = 0;
info->maxMem = vm->def->mem.max_balloon;
info->memory = vm->def->mem.cur_balloon;
@@ -949,8 +1007,7 @@ vmwareDomainGetState(virDomainPtr dom,
goto cleanup;
}
- *state = virDomainObjGetState(vm, reason);
- ret = 0;
+ ret = vmwareGetVMStatus(driver, vm, state, reason);
cleanup:
if (vm)
--
1.7.8.3
12 years, 8 months
[libvirt] [PATCH] apparmor: QEMU bridge helper policy updates
by Corey Bryant
This patch provides AppArmor policy updates for the QEMU bridge helper.
The QEMU bridge helper is a SUID executable exec'd by QEMU that drops
capabilities to CAP_NET_ADMIN and adds a tap device to a network
bridge. For more details on the helper, please refer to:
http://lists.gnu.org/archive/html/qemu-devel/2012-01/msg03562.html
Signed-off-by: Corey Bryant <coreyb(a)linux.vnet.ibm.com>
---
examples/apparmor/libvirt-qemu | 22 +++++++++++++++++++++-
1 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/examples/apparmor/libvirt-qemu b/examples/apparmor/libvirt-qemu
index 10cdd36..ee9ba5d 100644
--- a/examples/apparmor/libvirt-qemu
+++ b/examples/apparmor/libvirt-qemu
@@ -1,4 +1,4 @@
-# Last Modified: Mon Apr 5 15:11:27 2010
+# Last Modified: Fri Mar 9 14:43:22 2012
#include <abstractions/base>
#include <abstractions/consoles>
@@ -108,3 +108,23 @@
/bin/dash rmix,
/bin/dd rmix,
/bin/cat rmix,
+
+ /usr/libexec/qemu-bridge-helper Cx,
+
+ # child profile for bridge helper process
+ profile /usr/libexec/qemu-bridge-helper {
+ #include <abstractions/base>
+
+ capability setuid,
+ capability setgid,
+ capability setpcap,
+ capability net_admin,
+
+ network inet stream,
+
+ /dev/net/tun rw,
+ /etc/qemu/** r,
+ @{PROC}/*/status r,
+
+ /usr/libexec/qemu-bridge-helper rmix,
+ }
--
1.7.7
12 years, 8 months
[libvirt] [PATCH] Added support for AMD Bulldozer CPU
by Martin Kletzander
AMD Bulldozer (or Opteron_G4 as called in QEMU) was added to the list
of cpu models, flags were taken from upstream qemu cpu specifications
and should be sorted by bit values (or first occurence in the feature
specification part of cpu_map.xml).
Based on QEMU upstream commit 885bb0369a4f0abe2c0185178f3cb347cb02cdf1.
---
src/cpu/cpu_map.xml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/src/cpu/cpu_map.xml b/src/cpu/cpu_map.xml
index 6a6603b..8f80dd9 100644
--- a/src/cpu/cpu_map.xml
+++ b/src/cpu/cpu_map.xml
@@ -692,5 +692,53 @@
<feature name='misalignsse'/>
<feature name='lahf_lm'/>
</model>
+
+ <model name='Opteron_G4'>
+ <vendor name='AMD'/>
+ <feature name='fpu'/>
+ <feature name='de'/>
+ <feature name='pse'/>
+ <feature name='tsc'/>
+ <feature name='msr'/>
+ <feature name='pae'/>
+ <feature name='mce'/>
+ <feature name='cx8'/>
+ <feature name='apic'/>
+ <feature name='sep'/>
+ <feature name='mtrr'/>
+ <feature name='pge'/>
+ <feature name='mca'/>
+ <feature name='cmov'/>
+ <feature name='pat'/>
+ <feature name='pse36'/>
+ <feature name='clflush'/>
+ <feature name='mmx'/>
+ <feature name='fxsr'/>
+ <feature name='sse'/>
+ <feature name='sse2'/>
+ <feature name='pni'/>
+ <feature name='pclmuldq'/>
+ <feature name='ssse3'/>
+ <feature name='cx16'/>
+ <feature name='sse4.1'/>
+ <feature name='sse4.2'/>
+ <feature name='popcnt'/>
+ <feature name='aes'/>
+ <feature name='xsave'/>
+ <feature name='avx'/>
+ <feature name='syscall'/>
+ <feature name='nx'/>
+ <feature name='pdpe1gb'/>
+ <feature name='rdtscp'/>
+ <feature name='lm'/>
+ <feature name='lahf_lm'/>
+ <feature name='svm'/>
+ <feature name='abm'/>
+ <feature name='sse4a'/>
+ <feature name='misalignsse'/>
+ <feature name='3dnowprefetch'/>
+ <feature name='xop'/>
+ <feature name='fma4'/>
+ </model>
</arch>
</cpus>
--
1.7.3.4
12 years, 8 months