[Libvir] [PATCH] fix and update help.
by Atsushi SAKAI
This patch fix and update help.
1)update
virsh domstate, setvcpus supports inactive domain.
2)fix
4 points of adress => address
(xgettext needed for regenerate po file)
bridge.c | 4 ++--
virsh.c | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
Thanks
Tatsuro Enokura
Atsushi SAKAI
16 years, 7 months
[Libvir] [PATCH] Fix cdrom connect/disconnect for qemu
by Cole Robinson
The attached patch fixes cdrom changing for a live qemu guest. There
were a few issues preventing it from working:
1) It didn't anticipate no <source> block in the xml.
2) No support for ejecting the media
3) Small bug which prevented the running guest xml from being updated.
I've tested this via virt-manager, and now qemu and xen seem
to have parity wrt cdrom connect/disconnect.
Thanks,
Cole
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index e54da5b..ebbd251 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -594,9 +594,16 @@ static int qemudParseDiskXML(virConnectPtr conn,
}
if (source == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SOURCE, target ? "%s" : NULL, target);
- goto error;
+ /* There is a case without the source
+ * to the CD-ROM device
+ */
+ if (!device || STRNEQ((const char *) device, "cdrom")) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_NO_SOURCE,
+ target ? "%s" : NULL, target);
+ goto error;
+ }
}
+
if (target == NULL) {
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_TARGET, source ? "%s" : NULL, source);
goto error;
@@ -630,7 +637,7 @@ static int qemudParseDiskXML(virConnectPtr conn,
goto error;
}
- strncpy(disk->src, (const char *)source, NAME_MAX-1);
+ strncpy(disk->src, (source ? (const char *) source : "\0"), NAME_MAX-1);
disk->src[NAME_MAX-1] = '\0';
strncpy(disk->dst, (const char *)target, NAME_MAX-1);
@@ -1747,9 +1754,15 @@ int qemudBuildCommandLine(virConnectPtr conn,
char dev[NAME_MAX];
char file[PATH_MAX];
if (!strcmp(disk->dst, "hdc") &&
- disk->device == QEMUD_DISK_CDROM)
- snprintf(dev, NAME_MAX, "-%s", "cdrom");
- else
+ disk->device == QEMUD_DISK_CDROM) {
+ if (disk->src[0])
+ snprintf(dev, NAME_MAX, "-%s", "cdrom");
+ else {
+ /* Don't put anything on the cmdline for an empty cdrom*/
+ disk = disk->next;
+ continue;
+ }
+ } else
snprintf(dev, NAME_MAX, "-%s", disk->dst);
snprintf(file, PATH_MAX, "%s", disk->src);
@@ -2906,8 +2919,10 @@ char *qemudGenerateXML(virConnectPtr conn,
types[disk->type], devices[disk->device]) < 0)
goto no_memory;
- if (virBufferVSprintf(buf, " <source %s='%s'/>\n", typeAttrs[disk->type], disk->src) < 0)
- goto no_memory;
+ if (disk->src[0])
+ if (virBufferVSprintf(buf, " <source %s='%s'/>\n",
+ typeAttrs[disk->type], disk->src) < 0)
+ goto no_memory;
if (virBufferVSprintf(buf, " <target dev='%s'/>\n", disk->dst) < 0)
goto no_memory;
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index 21f0fed..2b4c2a6 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -2223,23 +2223,29 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
struct qemud_driver *driver = (struct qemud_driver *)dom->conn->privateData;
char *cmd, *reply, *safe_path;
- /* Migrate to file */
- safe_path = qemudEscapeMonitorArg(newdisk->src);
- if (!safe_path) {
- qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
- "out of memory");
- return -1;
- }
- if (asprintf (&cmd, "change %s \"%s\"",
- /* XXX qemu may support multiple CDROM in future */
- /* olddisk->dst */ "cdrom",
- safe_path) == -1) {
+ if (newdisk->src[0]) {
+ safe_path = qemudEscapeMonitorArg(newdisk->src);
+ if (!safe_path) {
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+ "out of memory");
+ return -1;
+ }
+ if (asprintf (&cmd, "change %s \"%s\"",
+ /* XXX qemu may support multiple CDROM in future */
+ /* olddisk->dst */ "cdrom",
+ safe_path) == -1) {
+ qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
+ "out of memory");
+ free(safe_path);
+ return -1;
+ }
+ free(safe_path);
+
+ } else if (asprintf(&cmd, "eject cdrom") == -1) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED,
"out of memory");
- free(safe_path);
return -1;
}
- free(safe_path);
if (qemudMonitorCommand(driver, vm, cmd, &reply) < 0) {
qemudReportError(dom->conn, dom, NULL, VIR_ERR_OPERATION_FAILED, "cannot change cdrom media");
@@ -2248,7 +2254,7 @@ static int qemudDomainChangeCDROM(virDomainPtr dom,
}
free(reply);
free(cmd);
- strcpy(olddisk->dst, newdisk->dst);
+ strcpy(olddisk->src, newdisk->src);
olddisk->type = newdisk->type;
return 0;
}
16 years, 7 months
[Libvir] Release of libvirt-0.4.1
by Daniel Veillard
It was really time for a new release, quite a lot of patches had accumulated
since the previous one ! Available at
ftp://libvirt.org/libvirt
* New features:
- build on MacOSX (Richard Jones)
- storage management (Daniel Berrange)
- Xenner - Xen on KVM - support (Daniel Berrange)
* Documentation:
- Fix of various typos (Atsushi SAKAI)
- memory and vcpu settings details (Richard Jones)
- ethernet bridging typo (Maxwell Bottiger)
- add storage APIs documentation (Daniel Berrange)
* Bug fixes:
- OpenVZ code compilation (Mikhail Pokidko)
- crash in policykit auth handling (Daniel Berrange)
- large config files (Daniel Berrange)
- cpumap hypercall size (Saori Fukuta)
- crash in remote auth (Daniel Berrange)
- ssh args error (Daniel Berrange)
- preserve vif order from config files (Hiroyuki Kaguchi)
- invalid pointer access (Jim Meyering)
- virDomainGetXMLDesc flag handling
- device name conversion on stats (Daniel Berrange)
- double mutex lock (Daniel Berrange)
- config file reading crashes (Guido Guenther)
- xenUnifiedDomainSuspend bug (Marcus Meissner)
- do not crash if /sys/hypervisor/capabilities is missing (Mark McLoughlin)
- virHashRemoveSet bug (Hiroyuki Kaguchi)
- close-on-exec flag for qemud signal pipe (Daniel Berrange)
- double free in OpenVZ (Anton Protopopov)
- handle mac without addresses (Shigeki Sakamoto)
- MAC addresses checks (Shigeki Sakamoto and Richard Jones)
* Improvements:
- Windows build (Richard Jones)
- KVM/QEmu shutdown (Guido Guenther)
- catch virExec output on debug (Mark McLoughlin)
- integration of iptables and lokkit (Mark McLoughlin)
- keymap parameter for VNC servers (Daniel Hokka Zakrisson)
- enable debug by default using VIR_DEBUG (Daniel Berrange)
- xen 3.2 fixes (Daniel Berrange)
- Python bindings for VCPU and scheduling (Daniel Berrange)
- framework for automatic code syntax checks (Jim Meyering)
- allow kernel+initrd setup in Xen PV (Daniel Berrange)
- allow change of Disk/NIC of an inactive domains (Shigeki Sakamoto)
- virsh commands to manipulate and create storage(Daniel Berrange)
- update use of PolicyKit APIs
- better detection of fedault hypervisor
- block device statistics for QEmu/KVM (Richard Jones)
- various improvements for Xenner (Daniel Berrange)
* Code cleanups:
- avoid warnings (Daniel Berrange)
- virRun helper function (Dan Berrange)
- iptable code fixes (Mark McLoughlin)
- static and const cleanups (Jim Meyering)
- malloc and python cleanups (Jim Meyering)
- xstrtol_ull and xstrtol_ll functions (Daniel Berrange)
- remove no-op networking from OpenVZ (Daniel Berrange)
- python generator cleanups (Daniel Berrange)
- cleanup ref counting (Daniel Berrange)
- remove uninitialized warnings (Jim Meyering)
- cleanup configure for RHEL4 (Daniel Berrange)
- CR/LF cleanups (Richard Jones)
- various automatic code check and associated cleanups (Jim Meyering)
- various memory leaks (Jim Meyering)
- fix compilation when building without Xen (Guido Guenther)
- mark translatables strings (Jim Meyering)
- use virBufferAddLit for constant strings (Jim Meyering)
- fix make distcheck (Jim Meyering)
- return values for python bindings (Cole Robinson)
- trailing blanks fixes (Jim Meyering)
- gcc-4.3.0 fixes (Mark McLoughlin)
- use safe read and write routines (Jim Meyering)
- refactoring of code dealing with hypervisor capabilities (Daniel Berrange)
- qemudReportError to use virErrorMsg (Cole Robinson)
- intemediate library and Makefiles for compiling static and coverage rule support (Jim Meyering)
- cleanup of various leaks (Jim Meyering)
Thanks to everybody who helped by providing code, patches or reporting
problems !
Daniel
--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard | virtualization library http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
16 years, 7 months
[Libvir] "virsh list" command of libvirt consumes a lot of CPU in the domain-0
by jean-paul.pigache@bull.net
Hi all,
I know that this is not a libvirt issue but this badly impacts libvirt
usage.
Is anyone aware of any status on this issue ? Daniel ?
Here is some history I could get from the libvirt mailing list :
* October 12, 2006 (Daniel Berrange).
I've been trying to track down just why talking to XenD is resulting in so
much CPU time being
comsumed by both xend & xenstored. As a test case, I'm running 'virsh
dominfo demo' which results in
a single HTTP request to Xend to fetch domain info, eg 'GET
/xend/domains/demo'
Run this in a tight loop & I'll see xenstored taking > 50% CPU, and XenD
taking another 11%
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
2647 root 16 0 6188 840 464 R 52 0.0 0:55.04 xenstored
11600 root 18 0 259m 7568 1516 S 11 0.2 0:04.53 python
Its not surprising that xend is consuming time since we are making many
requests per second, but for
an operation which is only doing reads it having so much time attributed
to xenstored seems very
excessive. So I ran oprofile & collected some data about xenstored:
CPU: AMD64 processors, speed 2211.33 MHz (estimated)
Counted CPU_CLK_UNHALTED events (Cycles outside of halt state) with a unit
mask of 0x00 (No
unit mask) count 100000
samples % image name symbol name
347226 45.9445 ext3 (no symbols)
264664 35.0200 jbd (no symbols)
31778 4.2048 libc-2.5.so memset
10763 1.4241 xenstored main
8884 1.1755 libc-2.5.so _int_malloc
7053 0.9332 libc-2.5.so vfprintf
4264 0.5642 xenstored initialize_set
So almost 80% of xenstored's CPU time is attributed to ext3 & journalling
modules, suggesting
xenstored is doing alot of disk I/O. strace()'ing the xenstored process
shows the only file it is opening
is:
# strace -p 2647 -e trace=open,rename,unlink
Process 2647 attached - interrupt to quit
open("/var/lib/xenstored/tdb.0x62aa80", O_WRONLY|O_CREAT|O_TRUNC, 0640) =
13
open("/var/lib/xenstored/tdb.0x62aa80", O_RDWR) = 15
rename("/var/lib/xenstored/tdb.0x62aa80", "/var/lib/xenstored/tdb") = 0
unlink("/var/lib/xenstored/tdb.0x62aa80") = -1 ENOENT (No such file or
directory)
open("/var/lib/xenstored/tdb.0x62b2b0", O_WRONLY|O_CREAT|O_TRUNC, 0640) =
13
open("/var/lib/xenstored/tdb.0x62b2b0", O_RDWR) = 14
rename("/var/lib/xenstored/tdb.0x62b2b0", "/var/lib/xenstored/tdb") = 0
unlink("/var/lib/xenstored/tdb.0x62b2b0") = -1 ENOENT (No such file or
directory)
...
So basically it is repeatedly copying its persistent TBD database over and
over again. The TDB on this
system is 128 KB in size and each individual HTTP GET on /xend/domain/demo
is resulting in 16
copies being made.
Do the maths - 128 * 16 == 2 MB of reads, and 2 MB of writes - for a
single read in XenD. Now if I
monitor the status of 20 domains, once per second that's causing 40 MB of
writes & 40 MB of reads
every second which is utterly ridiculous & completely non scalable for
enterprise deployment :-(
There's two problems I see here:
1. Why the need for xenstored to be doing any of this I/O in the first
place?
If the DB needs to be kept on disk at all, it really needs to have a much
saner update/transactional
model to only update bits which actually change, rather than re-creating
the entire DB on every
transaction. But it strikes me that the DB could potentially be kept
entirely in memory removing the
disk I/O completely. Sure yyou wouldn't be able to restart the daemon
then, but even today you can't
restart xenstored & expect things to still be working.
2. Why does XenD create sooo many transactions in XenStored for a read op
?
Having instrumented Xend it sems that the root cause of the problem is the
xen.xend.xenstore.xstransact class. This alllows one to start a
transaction, do a bunch of
reads/writes & then commit the transaction. At the same time though it has
a bunch of static
'convenience' methods for read & write which will implicitly start &
commit a transaction. Well
90% of the code in XenD seems to be using these 'convenience' methods
instead of explicitly
starting a transaction to cover a piece of work - the result is a simple
GET causes 16 transactions
....and an 'xm create' results in 80 transactions. These convenience
methods are utterly destroying
performance.
Clearly we can't address these for 3.0.3, but I think both of these areas
need serious work in 3.0.4 if we
want a scalable control plane in Dom0. Fixing the XenD bit looks
particularly hard because any single
method using the convenience xenstored read functions can be called under
many different contexts, so
of which needs transactions, others which don't. It ought to be possible
to trace back all the calls &
make it possible to pass explicit xstransct objects into all calls & then
kill off the convenience methods.
* Answer, same day (October 12, 2006)
Yes, xenstored is very simple minded in many respects. We will certainly
be improving this during
3.0.4 development -- I think we can get the costs down very significantly
for commonplace operations
without enormous effort.
* Avril 25, 2007 (Daniel Berrange)
> Xen 3.0.3 has a serious performance bug
> (see
http://lists.xensource.com/archives/html/xen-devel/2006-10/msg00487.html)
> This bug is fixed in Xen 3.0.4
No it isn't. The performance bug is actually at least x2 worse in Xen
3.0.4
16 years, 7 months
[Libvir] Snapshots for Xen and KVM
by Gabriel Kaufmann
Hi,
Does anyone knows if Xen and KVM support snapshots (regardless if Libvirt provides the API for them).
If yes, will libvirt add API for it?
Best Regards,
Gabriel Kaufmann
Software Engineer
Gabriel.Kaufmann(a)ericom.com<mailto:Gabriel.Kaufmann@ericom.com>
Ericom Software
Tel (Dir): +972 2 591 1700 Ext 754
Tel (Main): +972 2 591 1700
http://www.ericom.com
Access Done Right
Empower Enterprise-Wide Access to Microsoft(r) Terminal Server, Virtual Desktops and Legacy Applications
16 years, 7 months
Re: [Libvir] virsh start problem + patch
by Daniel P. Berrange
On Tue, Mar 11, 2008 at 06:57:33AM +0100, Toth Istvan wrote:
> # virsh list --all
> Id Name State
> ----------------------------------
> 0 Domain-0 running
> - windows-xen shut off
> - windows-xen2 no state
>
> # xm list
> Name ID Mem VCPUs State
> Time(s)
> Domain-0 0 3489 4 r-----
> 853.6
> windows-xen 1 512 0
> -b-s-d 39.4
> windows-xen2 4 512 0
> ------ 22.5
>
> The windows-xen, and windows-xen2 domains were installed the very same
> way, except I've had a Dom0 reboot since I've installed windows-xen, so
> xen has had the opportunity to sort it's state out, whil the
> windows-xen2 domain is a fresh install. Starting and stopping (by xm) a
> freshly installed windows hvm domain does not sort out the state, only a
> Dom0 reboot (or a xend restart) does.
>
> I have attached the output of xm list --long command.
This shows that it is all XenD related - inactive domains should *not*
have a 'domid' or 'state' field set in the 'xm list --long' output. In
both your windows-xen & windows-xen2 VM, these fields are incorrectly
present.
> This problem indeed does look like a Xend bug, but it turns out that it
> does not actually affect virsh. (It does affect virt-manager, as I've
> written to the other list)
> The other problem is I am pretty sure, a virsh logic bug, and is
> independent of the first one.
No, it is again a Xen bug. Inactive domains are *mandated* to have a
domain ID of -1. They do not exist in the hypervisor anymore and thus
have no domain ID associated with them. If XenD is not clearing the
domain ID properly this is a XenD problem.
That all said, we may need to workaround this XenD brokenness in the
libirt XenD driver. Working around it in virsh is the wrong place.
> and I get this:
>
> ./virsh start windows-xen
> <warnings>
> error: Domain is already active
> virDomainGetID(dom) returns 1
>
> ./virsh start windows-xen2
> <warnings>
> error: Domain is already active
> virDomainGetID(dom) returns 3
>
> so virDomainGetID() does not return -1, but returns the actual xen
> domain id of the managed, but inactive xen domain, and I believe this is
> what it should do,
> as it's job is not to tell us about the state of the domain, but to tell
> the id of the domain, regardles of its state.
No. Inactive domains are mandated to have an ID of -1.
Dan.
--
|: Red Hat, Engineering, Boston -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, 7 months
Re: [Libvir] Accessing qemu from windows
by Richard W.M. Jones
On Tue, Mar 11, 2008 at 06:00:31PM +0200, Gabriel Kaufmann wrote:
> I'm sure it actually makes a remote TCP connection since on the server side I get the error:
> 'libvir: error : could not connect to qemu:///system?'
It actually prints this out on the server side?
Can you run the server with the --verbose option, you'll get a lot
more detail about what is happening.
Rich.
--
Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into Xen guests.
http://et.redhat.com/~rjones/virt-p2v
16 years, 7 months
[Libvir] Accessing qemu from windows
by Gabriel Kaufmann
Hi,
I'm running virsh from linux machine with the URI qemu+tcp://<user>:<password>@<ip>/system
>From a linux machine (not the same that runs the libvirtd deamon) with libvirt 0.3.0, this URI allows me to connect.
In the other hand, using the Virsh.exe (that comes with ocaml-libvirt-0.4.0.1.exe<http://libvirt.org/sources/ocaml/ocaml-libvirt-0.4.0.1.exe> ) on Windows XP, I receive the error
'Virtualization error: libvirt: VIR_ERROR_NO_CONNECT: VIR_FROM_NONE: could not connect to qemu:///system?'
Is it a known bug, or is it configuration problem on my server?
Best Regards,
Gabriel Kaufmann
Software Engineer
Gabriel.Kaufmann(a)ericom.com<mailto:Gabriel.Kaufmann@ericom.com>
Ericom Software
Tel (Dir): +972 2 591 1700 Ext 754
Tel (Main): +972 2 591 1700
http://www.ericom.com
Access Done Right
Empower Enterprise-Wide Access to Microsoft(r) Terminal Server, Virtual Desktops and Legacy Applications
16 years, 7 months
[libvir] Could not connect to xend
by Anton Protopopov
Hi.
When I tried to run virsh to connect to xen, I have got an error --- libvirt
failed to open connection to xend.
Here is output with DEBUG enabled. What kind of additional information do
you need?
[root@localhost ~]# LIBVIRT_DEBUG=SPAM virsh
DEBUG: libvirt.c: virInitialize (register drivers)
DEBUG: libvirt.c: virConnectOpenAuth (name=(null), auth=0xb7ed79d8, flags=0)
DEBUG: libvirt.c: do_open (Probed xen:///)
DEBUG: libvirt.c: do_open (Using xen:/// as default URI, 1 hypervisor found)
DEBUG: libvirt.c: do_open (name "xen:///" to URI components:
scheme xen
opaque (null)
authority (null)
server (null)
user (null)
port 0
path /
)
DEBUG: libvirt.c: do_open (trying driver 0 (Test) ...)
DEBUG: libvirt.c: do_open (driver 0 Test returned DECLINED)
DEBUG: libvirt.c: do_open (trying driver 1 (QEMU) ...)
DEBUG: libvirt.c: do_open (driver 1 QEMU returned DECLINED)
DEBUG: libvirt.c: do_open (trying driver 2 (Xen) ...)
DEBUG: xen_unified.c: xenUnifiedOpen (trying Xen sub-driver 0)
DEBUG: xen_unified.c: xenUnifiedOpen (Xen sub-driver 0 open ok
)
DEBUG: xen_unified.c: xenUnifiedOpen (trying Xen sub-driver 2)
libvir: Xen Daemon error : internal error failed to connect to xend
libvir: Xen Daemon error : internal error failed to connect to xend
DEBUG: xen_unified.c: xenUnifiedOpen (Xen sub-driver 2 open failed
)
DEBUG: libvirt.c: do_open (driver 2 Xen returned ERROR)
DEBUG: hash.c: virUnrefConnect (unref connection 0x807bf88 xen:/// 1)
DEBUG: hash.c: virReleaseConnect (release connection 0x807bf88 xen:///)
error: failed to connect to the hypervisor
16 years, 7 months