[libvirt] [PATCH] Fix cd eject segfault
by Cole Robinson
The cdrom eject code was trying to dereference the
NULL source of an empty cdrom. Attached patch fixes
this.
Thanks,
Cole
commit 5925689b5b94b29a520dcfbc7f4f1cfa0a0a0183
Author: Cole Robinson <crobinso(a)dhcp-100-19-219.bos.redhat.com>
Date: Thu Aug 21 17:56:25 2008 -0400
Prevent cdrom eject from segfaulting when setting new disk source.
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 06fbe55..769f34f 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2953,6 +2953,7 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
virDomainDiskDefPtr newdisk) {
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
char *cmd, *reply, *safe_path;
+ char *newsrc = NULL;
if (newdisk->src) {
safe_path = qemudEscapeMonitorArg(newdisk->src);
@@ -2972,6 +2973,13 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
}
VIR_FREE(safe_path);
+ newsrc = strdup(newdisk->src);
+ if (!newsrc) {
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+ "%s", _("out of memory"));
+ return -1;
+ }
+
} else if (asprintf(&cmd, "eject cdrom") == -1) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("out of memory"));
@@ -2982,11 +2990,17 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"%s", _("cannot change cdrom media"));
VIR_FREE(cmd);
+ VIR_FREE(newsrc);
return -1;
}
VIR_FREE(reply);
VIR_FREE(cmd);
- strcpy(olddisk->src, newdisk->src);
+
+ VIR_FREE(olddisk->src);
+ if (newsrc) {
+ olddisk->src = newsrc;
+ newsrc = NULL;
+ }
olddisk->type = newdisk->type;
return 0;
}
16 years, 4 months
[libvirt] [PATCH] Delete veth devices during lxcVMCleanup
by Dan Smith
This makes sure to delete veth devices after we've killed the container.
In the case of a destroy or crash, this ensures the system is cleaned
up properly.
To be applied atop Daniel Berrange's current LXC patch stack.
diff -r b18ae864eb98 -r cd0bd9a6288a src/lxc_driver.c
--- a/src/lxc_driver.c Wed Aug 13 09:40:08 2008 -0700
+++ b/src/lxc_driver.c Thu Aug 14 08:50:49 2008 -0700
@@ -375,6 +375,7 @@
int rc = -1;
int waitRc;
int childStatus = -1;
+ virDomainNetDefPtr net;
while (((waitRc = waitpid(vm->pid, &childStatus, 0)) == -1) &&
errno == EINTR)
@@ -403,6 +404,11 @@
vm->pid = -1;
vm->def->id = -1;
vm->monitor = -1;
+
+ for (net = vm->def->nets; net; net = net->next) {
+ vethInterfaceUpOrDown(net->ifname, 0);
+ vethDelete(net->ifname);
+ }
return rc;
}
16 years, 4 months
[libvirt] [PATCH] Check disk target collision when parsing domain xml
by Cole Robinson
The current domain xml parsing doesn't check if disks
are specified with duplicate targets ("hda" etc.). The
attached patch adds a check for this.
Thanks,
Cole
commit 27df1653474738a2ce83c89e7bdb2c4f7327f9b6
Author: Cole Robinson <crobinso(a)dhcp-100-19-219.bos.redhat.com>
Date: Thu Aug 21 14:58:04 2008 -0400
Check for duplicate disk targets when parsing domain xml.
diff --git a/src/domain_conf.c b/src/domain_conf.c
index 6b23474..ed6cc8b 100644
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -1955,6 +1955,12 @@ static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
} else {
virDomainDiskDefPtr ptr = def->disks;
while (ptr) {
+ if (ptr->next && STREQ(disk->dst, ptr->next->dst)) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("duplicate disk target '%s'"),
+ disk->dst);
+ goto error;
+ }
if (!ptr->next || virDomainDiskCompare(disk, ptr->next) < 0) {
disk->next = ptr->next;
ptr->next = disk;
16 years, 4 months
RE: [libvirt] Using Xen config files
by Matthew Donovan
Xen and Xen-devel are 3.1.2.
I'm using version 0.4.4 of libvirt.
-matthew
> -----Original Message-----
> From: Richard W.M. Jones [mailto:rjones@redhat.com]
> Sent: Friday, August 22, 2008 4:19 AM
> To: Matthew Donovan
> Cc: Daniel P. Berrange; libvir-list(a)redhat.com
> Subject: Re: [libvirt] Using Xen config files
>
> On Thu, Aug 21, 2008 at 02:16:55PM -0400, Matthew Donovan wrote:
> > I'm still having problems with this. I've dug around and
> found errors in
> > the qemu-dm log.
> >
> > When I try to start the VM with libvirt, the error I'm getting is:
> >
> "xs_read(/vm/414e73de-cf1e-487c-87e0-d4ebf7a23576/rtc/timeoffs
> et): read
> > error"
> >
> > I did a xenstore-ls on the /vm/414e73de-cf1e-487c-87e0-d4ebf7a23576
> > directory and sure enough, rtc/timeoffset is not there.
> When I start the VM
> > with the Xen config file I used to generate the XML the
> rtc/timeoffset is
> > there (timeoffset is set to "0").
>
> Which version of xen, xen-devel, etc?
>
> Rich.
>
> --
> Richard Jones, Emerging Technologies, Red Hat
> http://et.redhat.com/~rjones
> virt-df lists disk usage of guests without needing to install any
> software inside the virtual machine. Supports Linux and Windows.
> http://et.redhat.com/~rjones/virt-df/
>
16 years, 4 months
[libvirt] PATCH: Improve python exception messages
by Daniel P. Berrange
Most of the libvirt python API bindings use code snippet like this when
raising an exception:
if ret is None:raise libvirtError('virConnectOpen() failed')
THis sets the message associated with the exception to
"virConnectOpen() failed"
This contains essentially zero useful information - you can see that it
was virConnectOpen which failed from the stack trace.
Now the libvirt error object has a real message, such as
"authentication failed"
Or
"unable to connect to '/var/run/libvirt/libvirt-sock': Connection refused"
This patch makes sure we extract this real error message and use it to
set the message associated with the exception object. This is one step
in getting better error reporting for virt-install/virt-manager, which
is particularly needed for remote connections
Daniel
diff -u -r1.9 libvir.py
--- python/libvir.py 11 Jun 2008 07:49:01 -0000 1.9
+++ python/libvir.py 18 Aug 2008 12:07:03 -0000
@@ -13,10 +13,22 @@
import types
+def _getErrorMessage(conn, defmsg):
+ err = None
+ if conn is None:
+ err = virGetLastError()
+ else:
+ err = conn.virConnGetLastError()
+ if err is None:
+ return defmsg
+ else:
+ return err[2]
+
+
# The root of all libvirt errors.
class libvirtError(Exception):
def __init__(self, msg, conn=None, dom=None, net=None, pool=None, vol=None):
- Exception.__init__(self, msg)
+ Exception.__init__(self, _getErrorMessage(conn, msg))
if dom is not None:
conn = dom._conn
@@ -77,12 +89,6 @@
return None
return self.err[8]
- def __str__(self):
- if self.get_error_message() is None:
- return Exception.__str__(self)
- else:
- return Exception.__str__(self) + " " + self.get_error_message()
-
#
# register the libvirt global error handler
#
--
|: 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, 4 months
[libvirt] pthread_sigmask undefined reference error
by Jun Koi
Hi,
The latest cvs version has an error when compiling:
make[3]: Entering directory `/home/jun/projects/libvirt-0821/src'
/bin/bash ../libtool --tag=CC --mode=link gcc -g -O2 -Wall
-Wformat -Wformat-security -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings
-Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
-Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fasynchronous-unwind-tables -o virsh virsh-console.o
virsh-util-lib.o virsh-virsh.o -Wall -Wformat -Wformat-security
-Wmissing-prototypes -Wnested-externs -Wpointer-arith -Wextra -Wshadow
-Wcast-align -Wwrite-strings -Waggregate-return -Wstrict-prototypes
-Winline -Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fasynchronous-unwind-tables libvirt.la
../gnulib/lib/libgnu.la
gcc -g -O2 -Wall -Wformat -Wformat-security -Wmissing-prototypes
-Wnested-externs -Wpointer-arith -Wextra -Wshadow -Wcast-align
-Wwrite-strings -Waggregate-return -Wstrict-prototypes -Winline
-Wredundant-decls -Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2
-fexceptions -fasynchronous-unwind-tables -o .libs/virsh
virsh-console.o virsh-util-lib.o virsh-virsh.o -Wall -Wformat
-Wformat-security -Wmissing-prototypes -Wnested-externs
-Wpointer-arith -Wextra -Wshadow -Wcast-align -Wwrite-strings
-Waggregate-return -Wstrict-prototypes -Winline -Wredundant-decls
-Wno-sign-compare -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fasynchronous-unwind-tables ./.libs/libvirt.so
../gnulib/lib/.libs/libgnu.a
./.libs/libvirt.so: undefined reference to `pthread_sigmask'
collect2: ld returned 1 exit status
make[3]: *** [virsh] Error 1
make[3]: Leaving directory `/home/jun/projects/libvirt-0821/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/jun/projects/libvirt-0821/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/jun/projects/libvirt-0821'
make: *** [all] Error 2
It seems I lack a particular library??
Thanks,
Jun
16 years, 4 months
[libvirt] [PATCH] autobuild.sh: Fix minor shell-quoting bugs.
by Jim Meyering
I noticed some minor quoting problems in ovirt's autobuild.sh,
and since part of that code came from here, ...
Here's a patch:
>From 50c37706729b7748dbf92290c6ecf6bc3982f681 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering(a)redhat.com>
Date: Thu, 21 Aug 2008 17:55:19 +0200
Subject: [PATCH] autobuild.sh: Fix minor shell-quoting bugs.
* autobuild.sh: Remove unnecessary quotes.
Don't choke on a file name argument containing a space.
Don't misbehave for $AUTOBUILD_INSTALL_ROOT containing
a shell meta-character.
---
autobuild.sh | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/autobuild.sh b/autobuild.sh
index ce12692..7ae5d1e 100755
--- a/autobuild.sh
+++ b/autobuild.sh
@@ -5,7 +5,7 @@ set -v
# Make things clean.
-test -n "$1" && RESULTS="$1" || RESULTS="results.log"
+test -n "$1" && RESULTS=$1 || RESULTS=results.log
test -f Makefile && make -k distclean || :
rm -rf coverage
@@ -14,7 +14,7 @@ rm -rf coverage
#mkdir build
#cd build
-./autogen.sh --prefix=$AUTOBUILD_INSTALL_ROOT \
+./autogen.sh --prefix="$AUTOBUILD_INSTALL_ROOT" \
--enable-test-coverage \
--enable-compile-warnings=error \
--with-openvz \
@@ -25,8 +25,8 @@ make
make install
set -o pipefail
-make check 2>&1 | tee $RESULTS
-make syntax-check 2>&1 | tee -a $RESULTS
+make check 2>&1 | tee "$RESULTS"
+make syntax-check 2>&1 | tee -a "$RESULTS"
test -x /usr/bin/lcov && make cov
rm -f *.tar.gz
--
1.6.0.90.g436ed
16 years, 4 months
RE: [libvirt] Using Xen config files
by Matthew Donovan
I'm still having problems with this. I've dug around and found errors in
the qemu-dm log.
When I try to start the VM with libvirt, the error I'm getting is:
"xs_read(/vm/414e73de-cf1e-487c-87e0-d4ebf7a23576/rtc/timeoffset): read
error"
I did a xenstore-ls on the /vm/414e73de-cf1e-487c-87e0-d4ebf7a23576
directory and sure enough, rtc/timeoffset is not there. When I start the VM
with the Xen config file I used to generate the XML the rtc/timeoffset is
there (timeoffset is set to "0").
Is there a way to set that in the XML? I didn't see it in the online XML
description.
I'm using a slightly different XML description than I had originally so I've
included here (along with the Xen Config file)
Thanks!
-matthew
const char* foo =
"<domain type='xen'>"
"<name>LinuxVM</name>"
"<uuid>414e73de-cf1e-487c-87e0-d4ebf7a23576</uuid>"
"<os>"
"<type>hvm</type>"
"<loader>/usr/lib/xen/boot/hvmloader</loader>"
"<boot dev='hd'/>"
"</os>"
"<memory>512000</memory>"
"<vcpu>1</vcpu>"
"<on_shutdown>shutdown</on_shutdown>"
"<on_reboot>restart</on_reboot>"
"<on_crash>restart</on_crash>"
"<features>"
"<pae/>"
"<acpi/>"
"<apic/>"
"</features>"
"<clock sync='localtime'/>"
"<devices>"
"<emulator>/usr/lib/xen/bin/qemu-dm</emulator>"
"<disk type='block'>"
"<source dev='/dev/vgvms/LinuxVM'/>"
"<target dev='hda'/>"
"</disk>"
"<interface type='ioemu'>"
"<mac address='7A:AB:D0:01:82:98'/>"
"</interface>"
"<input type='tablet' bus='usb'/>"
"<graphics type='sdl' password=''/>"
"<serial type='pty'/>"
"</devices>"
"</domain>";
//serial = "pty"
int main (int argc, char** argv)
{
virConnectPtr con; /* connection to the Xen hypervisor */
virDomainPtr domain;
virInitialize();
con = virConnectOpen ("xen:///");
if (!con) {
virErrorPtr err = virGetLastError ();
printf ("virConnectOpen failed: %s\n",
err->message);
return -1;
}
domain = virDomainDefineXML (con, foo);
if (!domain) {
virErrorPtr err = virConnGetLastError (con);
printf ("virDomainDefineXML failed: %s\n",
err->message);
} else {
if (virDomainCreate (domain) < 0) {
virErrorPtr err = virConnGetLastError (con);
printf ("virDomainCreate failed: %s\n",
err->message);
} else {
virDomainInfo info = {0};
virDomainGetInfo (domain, &info);
printf ("state = %d\n", info.state);
getchar ();
}
}
virConnectClose (con);
return 0;
}
# Automatically generated xen config file
name = "LinuxVM"
builder = "hvm"
memory = "500"
disk = [ 'phy:/dev/vgvms/LinuxVM,hda,w', ]
vif = [ 'type=ioemu, mac=7A:AB:D0:01:82:98', ]
uuid = "414e73de-cf1e-487c-87e0-d4ebf7a23576"
device_model = "/usr/lib/xen/bin/qemu-dm"
kernel = "/usr/lib/xen/boot/hvmloader"
vnc=1
vnc=0
sdl=1
stdvga=0
boot="cda"
usbdevice="tablet"
vncunused=1
apic=1
acpi=1
pae=1
vcpus=1
serial = "pty"
on_reboot = 'restart'
on_crash = 'restart'
> -----Original Message-----
> From: Daniel P. Berrange [mailto:berrange@redhat.com]
> Sent: Wednesday, August 20, 2008 1:05 PM
> To: Richard W.M. Jones
> Cc: Matthew Donovan; libvir-list(a)redhat.com
> Subject: Re: [libvirt] Using Xen config files
>
> On Wed, Aug 20, 2008 at 04:44:04PM +0100, Richard W.M. Jones wrote:
> > On Wed, Aug 20, 2008 at 11:35:17AM -0400, Matthew Donovan wrote:
> >
> > It certainly looks OK, and it seems like the domain should run after
> > virDomainCreate. Have you tried adding a delay of 30
> seconds just to
> > check if the domain is starting up slowly?
>
> Yep, that debug suggests the libvirt part of creation has
> completed OK.
> I think if anything is going wrong, its going to be in XenD's
> arena. I'd
> recommend looking in /var/log/xen for any further hints of trouble
>
> 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, 4 months
Re: [libvirt] Libvirt Xen daemon interaction in Red Hat Enterprise with virtualization
by vaibhav chugh
Thanks a lot for the reply. I checked the setting in my config file and they
look correct as specified by the webpage. I am able to connect to the unix
socket but my login to xend is failing.
What I am looking for is the exact function call that is made by libvirt to
connect to xen daemon. i.e. the function that makes libvirt send out xml RPC
message for xend to read.
session.login_with_password() is not supported by xenAPI version being used
in Red Hat. Please help me with the substitute of this method in Red Hat.
Thanks
Vaibhav
>
>
>
> On Wed, Aug 20, 2008 at 10:18 AM, Daniel P. Berrange <berrange(a)redhat.com>wrote:
>
>> On Wed, Aug 20, 2008 at 10:15:49AM -0700, vaibhav chugh wrote:
>> > Hi,
>> >
>> > I am new to libvirt and I am trying to figure out that how libvert
>> connects
>> > to Xend in Red Hat Enterprise with virtualization. I read a few posts
>> but
>> > was not able to find this out.
>> >
>> > The eariler versions of Xen were using xen_session_login_with_password()
>> > function call to connect to Xen daemon but I am not able to find
>> anything
>> > similar to this in libvirt.
>>
>> Libvirt talks to XenD using its UNIX socket, and SEXPR interface. This
>> page gives a quick list of config settings you need in XenD to make it
>> work with libvirt:
>>
>> http://libvirt.org/drvxen.html
>>
>> 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/ <http://search.cpan.org/%7Edanberr/> :|
>> |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505
>> :|
>>
>
>
>
> --
> Vaibhav Chugh
>
16 years, 4 months