[Libvir] Reopening the old discussion about virDomainBlockPeek

Virt-df[1] has now gained the ability to fully parse LVM2 partitions, thus: # virt-df -c qemu:///system -h Filesystem Size Used Available Type rhel51x32kvm:hda1 96.8 MiB 14.6 MiB 82.2 MiB Linux ext2/3 rhel51x32kvm:VolGroup00/LogVol00 6.4 GiB 3.6 GiB 2.8 GiB Linux ext2/3 rhel51x32kvm:VolGroup00/LogVol01 992.0 MiB Linux swap However it still has to do it by opening the local partitions / files, which means it isn't using a "proper" part of libvirt and more importantly it cannot run remotely. I'd like to find out whether the time has come for us to look again at a virDomainBlockPeek call for libvirt. Here is the original thread plus patch from 7 months ago: http://www.redhat.com/archives/libvir-list/2007-October/thread.html#00089 (I've attached an updated patch against current CVS). I appreciate that some cases might not be simple (iSCSI?), but the same argument applies to block device statistics too, and we make those available where possible. I think a best-effort call allowing callers to peek into the block devices of guests would be very useful. Rich. [1] http://hg.et.redhat.com/applications/virt/applications/virt-df--devel -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

On Wed, Apr 16, 2008 at 04:18:31PM +0100, Richard W.M. Jones wrote:
Virt-df[1] has now gained the ability to fully parse LVM2 partitions, thus:
# virt-df -c qemu:///system -h Filesystem Size Used Available Type rhel51x32kvm:hda1 96.8 MiB 14.6 MiB 82.2 MiB Linux ext2/3 rhel51x32kvm:VolGroup00/LogVol00 6.4 GiB 3.6 GiB 2.8 GiB Linux ext2/3 rhel51x32kvm:VolGroup00/LogVol01 992.0 MiB Linux swap
However it still has to do it by opening the local partitions / files, which means it isn't using a "proper" part of libvirt and more importantly it cannot run remotely.
I'd like to find out whether the time has come for us to look again at a virDomainBlockPeek call for libvirt. Here is the original thread plus patch from 7 months ago:
http://www.redhat.com/archives/libvir-list/2007-October/thread.html#00089
(I've attached an updated patch against current CVS).
I appreciate that some cases might not be simple (iSCSI?), but the same argument applies to block device statistics too, and we make those available where possible. I think a best-effort call allowing callers to peek into the block devices of guests would be very useful.
While I don't particularly like the idea of adding a general API for reading data from guest disks, I think given that clear & valid use case from the virt-df, we should go ahead and add the virDomainBlockPeek API. It will be rather fun for virt-df to deal with non-raw devices like qcow but that's not really a concern for libvirt...
Index: configure.in =================================================================== RCS file: /data/cvs/libvirt/configure.in,v retrieving revision 1.139 diff -u -r1.139 configure.in --- configure.in 8 Apr 2008 16:45:57 -0000 1.139 +++ configure.in 16 Apr 2008 15:18:07 -0000 @@ -60,6 +60,10 @@
LIBVIRT_COMPILE_WARNINGS(maximum)
+dnl Support large files / 64 bit seek offsets. +dnl Use --disable-largefile if you don't want this. +AC_SYS_LARGEFILE +
IIRC, this is redundant now - we already added it elsewhere in the configure script when we did the storage patches.
- +int virDomainBlockPeek (virDomainPtr dom, + const char *path, + long long offset, + size_t size, + void *buffer);
Should probably make offset be an 'unsigned long long' unless we have some semantics which want -ve numbers ? Is 'char *' better or worse than 'void *' for the buffer arg ?
+/* "domblkpeek" command + */ +static vshCmdInfo info_domblkpeek[] = { + {"syntax", "domblkpeek <domain> <path> <offset> <size>"}, + {"help", gettext_noop("peek at a domain block device")}, + {"desc", gettext_noop("Peek into a domain block device.")}, + {NULL,NULL} +}; + +static vshCmdOptDef opts_domblkpeek[] = { + {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")}, + {"path", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("block device path")}, + {"offset", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("start offset")}, + {"size", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("size in bytes")}, + {NULL, 0, 0, NULL} +};
I'm wondering if this is perhaps one of the few APIs we should /not/ include in virsh ? The data is pretty useless on its own - I figure any app needing to access this is almost certainly not going to be shell scripting, and thus using one of the language bindings directly. Having the virsh command will probably just encourage people to use this as a really dumb file copy command.
+ /* The path is correct, now try to open it and get its size. */ + fd = open (path, O_RDONLY); + if (fd == -1 || fstat (fd, &statbuf) == -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + } + + /* XXX The following test fails for LVM devices for a couple + * of reasons: (1) They are commonly symlinks to /dev/mapper/foo + * and despite the man page for fstat, fstat stats the link not + * the file. (2) Stat even on the block device returns st_size==0. + * + * Anyhow, it should be safe to ignore this test since we are + * in O_RDONLY mode. + */ +#if 0 + /* NB we know offset > 0, size >= 0 */ + if (offset + size > statbuf.st_size) { + virXendError (domain->conn, VIR_ERR_INVALID_ARG, "offset"); + goto done; + } +#endif
Actually the core problem is that fstat() does not return block device capacity. The best way to determine capacity of a block device is to lseek() to the end of it, and grab the return value of lseek. There's also a Linux speciifc ioctl() to get device capacity, but the lseek approach is portable.
+ + /* Seek and read. */ + /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should + * be 64 bits on all platforms. + */ + if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || + saferead (fd, buffer, size) == (ssize_t) -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + } + + ret = 0; + done: + if (fd >= 0) close (fd); + return ret; +} + #endif /* ! PROXY */ #endif /* WITH_XEN */ Index: src/xend_internal.h =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.h,v retrieving revision 1.40 diff -u -r1.40 xend_internal.h --- src/xend_internal.h 10 Apr 2008 16:54:54 -0000 1.40 +++ src/xend_internal.h 16 Apr 2008 15:18:26 -0000 @@ -228,6 +228,8 @@ int xenDaemonDomainMigratePrepare (virConnectPtr dconn, char **cookie, int *cookielen, const char *uri_in, char **uri_out, unsigned long flags, const char *dname, unsigned long resource); int xenDaemonDomainMigratePerform (virDomainPtr domain, const char *cookie, int cookielen, const char *uri, unsigned long flags, const char *dname, unsigned long resource);
+int xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path, long long offset, size_t size, void *buffer); + #ifdef __cplusplus } #endif Index: src/xm_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xm_internal.c,v retrieving revision 1.70 diff -u -r1.70 xm_internal.c --- src/xm_internal.c 10 Apr 2008 16:54:54 -0000 1.70 +++ src/xm_internal.c 16 Apr 2008 15:18:29 -0000 @@ -3160,4 +3160,15 @@ return (ret); }
+int +xenXMDomainBlockPeek (virDomainPtr dom, + const char *path ATTRIBUTE_UNUSED, + long long offset ATTRIBUTE_UNUSED, + size_t size ATTRIBUTE_UNUSED, + void *buffer ATTRIBUTE_UNUSED) +{ + xenXMError (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + return -1; +}
Hmm, is there no way to share the code here with the main Xen driver ? THe XenD driver impl parses the SEXPR to get the device info. Perhaps we could parse the XML format instead, then the only difference would be the API you call to get the XML doc in each driver. For that matter, if we worked off the XML format, this driver impl would be trivially sharable to QEMU and LXC, etc too. Regards, Daniel. -- |: 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 :|

Attached is an updated patch. The changes are: - updated to latest CVS - run make check / syntax-check - remove virsh subcommand (as per Dan's suggestion - see below) - some more things that Dan pointed out - see below I would like to add this to CVS because it is quite a pain tracking CVS changes. I know there's no remote support at the moment, but I can add that later. On Thu, Apr 24, 2008 at 03:02:11PM +0100, Daniel P. Berrange wrote:
Index: configure.in =================================================================== RCS file: /data/cvs/libvirt/configure.in,v retrieving revision 1.139 diff -u -r1.139 configure.in --- configure.in 8 Apr 2008 16:45:57 -0000 1.139 +++ configure.in 16 Apr 2008 15:18:07 -0000 @@ -60,6 +60,10 @@
LIBVIRT_COMPILE_WARNINGS(maximum)
+dnl Support large files / 64 bit seek offsets. +dnl Use --disable-largefile if you don't want this. +AC_SYS_LARGEFILE +
IIRC, this is redundant now - we already added it elsewhere in the configure script when we did the storage patches.
In the patch I removed the second AC_SYS_LARGEFILE and left the useful comment.
- +int virDomainBlockPeek (virDomainPtr dom, + const char *path, + long long offset, + size_t size, + void *buffer);
Should probably make offset be an 'unsigned long long' unless we have some semantics which want -ve numbers ? Is 'char *' better or worse than 'void *' for the buffer arg ?
I changed the offset to unsigned long long. Left the buffer as void *.
+/* "domblkpeek" command + */ +static vshCmdInfo info_domblkpeek[] = { + {"syntax", "domblkpeek <domain> <path> <offset> <size>"}, + {"help", gettext_noop("peek at a domain block device")}, + {"desc", gettext_noop("Peek into a domain block device.")}, + {NULL,NULL} +}; + +static vshCmdOptDef opts_domblkpeek[] = { + {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("domain name, id or uuid")}, + {"path", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("block device path")}, + {"offset", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("start offset")}, + {"size", VSH_OT_DATA, VSH_OFLAG_REQ, gettext_noop("size in bytes")}, + {NULL, 0, 0, NULL} +};
I'm wondering if this is perhaps one of the few APIs we should /not/ include in virsh ? The data is pretty useless on its own - I figure any app needing to access this is almost certainly not going to be shell scripting, and thus using one of the language bindings directly. Having the virsh command will probably just encourage people to use this as a really dumb file copy command.
This virsh changed removed.
+ /* The path is correct, now try to open it and get its size. */ + fd = open (path, O_RDONLY); + if (fd == -1 || fstat (fd, &statbuf) == -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + } + + /* XXX The following test fails for LVM devices for a couple + * of reasons: (1) They are commonly symlinks to /dev/mapper/foo + * and despite the man page for fstat, fstat stats the link not + * the file. (2) Stat even on the block device returns st_size==0. + * + * Anyhow, it should be safe to ignore this test since we are + * in O_RDONLY mode. + */ +#if 0 + /* NB we know offset > 0, size >= 0 */ + if (offset + size > statbuf.st_size) { + virXendError (domain->conn, VIR_ERR_INVALID_ARG, "offset"); + goto done; + } +#endif
Actually the core problem is that fstat() does not return block device capacity. The best way to determine capacity of a block device is to lseek() to the end of it, and grab the return value of lseek.
There's also a Linux speciifc ioctl() to get device capacity, but the lseek approach is portable.
I just removed this code. It's not needed.
+ + /* Seek and read. */ + /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should + * be 64 bits on all platforms. + */ + if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || + saferead (fd, buffer, size) == (ssize_t) -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + } + + ret = 0; + done: + if (fd >= 0) close (fd); + return ret; +} + #endif /* ! PROXY */ #endif /* WITH_XEN */ Index: src/xend_internal.h =================================================================== RCS file: /data/cvs/libvirt/src/xend_internal.h,v retrieving revision 1.40 diff -u -r1.40 xend_internal.h --- src/xend_internal.h 10 Apr 2008 16:54:54 -0000 1.40 +++ src/xend_internal.h 16 Apr 2008 15:18:26 -0000 @@ -228,6 +228,8 @@ int xenDaemonDomainMigratePrepare (virConnectPtr dconn, char **cookie, int *cookielen, const char *uri_in, char **uri_out, unsigned long flags, const char *dname, unsigned long resource); int xenDaemonDomainMigratePerform (virDomainPtr domain, const char *cookie, int cookielen, const char *uri, unsigned long flags, const char *dname, unsigned long resource);
+int xenDaemonDomainBlockPeek (virDomainPtr domain, const char *path, long long offset, size_t size, void *buffer); + #ifdef __cplusplus } #endif Index: src/xm_internal.c =================================================================== RCS file: /data/cvs/libvirt/src/xm_internal.c,v retrieving revision 1.70 diff -u -r1.70 xm_internal.c --- src/xm_internal.c 10 Apr 2008 16:54:54 -0000 1.70 +++ src/xm_internal.c 16 Apr 2008 15:18:29 -0000 @@ -3160,4 +3160,15 @@ return (ret); }
+int +xenXMDomainBlockPeek (virDomainPtr dom, + const char *path ATTRIBUTE_UNUSED, + long long offset ATTRIBUTE_UNUSED, + size_t size ATTRIBUTE_UNUSED, + void *buffer ATTRIBUTE_UNUSED) +{ + xenXMError (dom->conn, VIR_ERR_NO_SUPPORT, __FUNCTION__); + return -1; +}
Hmm, is there no way to share the code here with the main Xen driver ? THe XenD driver impl parses the SEXPR to get the device info. Perhaps we could parse the XML format instead, then the only difference would be the API you call to get the XML doc in each driver. For that matter, if we worked off the XML format, this driver impl would be trivially sharable to QEMU and LXC, etc too.
I left this as it was because I'm not sure what you are suggesting. Do you mean to do a dumpxml operation inside the driver? Note that we're already dumping the XML outside the driver in order to get the paths to pass in. 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

On Wed, Jun 04, 2008 at 04:10:32PM +0100, Richard W.M. Jones wrote:
Attached is an updated patch. The changes are:
- updated to latest CVS - run make check / syntax-check - remove virsh subcommand (as per Dan's suggestion - see below) - some more things that Dan pointed out - see below
I would like to add this to CVS because it is quite a pain tracking CVS changes. I know there's no remote support at the moment, but I can add that later. [...] +int virDomainBlockPeek (virDomainPtr dom, + const char *path, + unsigned long long offset, + size_t size, + void *buffer);
hum, we should add a flags extra data. And based on some IRC discussion you already have an use for this. The API feels a bit dangerous to me, because this is a completely unstructured API, you just get data, you have a priori no way to analyze what it returns. But I understand why you need it and I don't see a workaround. So I'm fine with this, it's a bit of a trick, it probably won't work in all cases, but it's still read only and allow to do some analysis, so that's okay. Once you have commited the revised version of the API it woudl be nice to not wait too much for the remote support if possible.
Index: tests/sexpr2xmldata/sexpr2xml-curmem.xml =================================================================== RCS file: /data/cvs/libvirt/tests/sexpr2xmldata/sexpr2xml-curmem.xml,v retrieving revision 1.6 diff -b -u -p -r1.6 sexpr2xml-curmem.xml --- tests/sexpr2xmldata/sexpr2xml-curmem.xml 8 May 2008 14:41:56 -0000 1.6 +++ tests/sexpr2xmldata/sexpr2xml-curmem.xml 4 Jun 2008 15:08:24 -0000 @@ -15,17 +15,17 @@ <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> + <disk type='file' device='disk'> + <driver name='tap' type='aio'/> + <source file='/xen/rhel5.img'/> + <target dev='xvda' bus='xen'/> + </disk> <interface type='bridge'> <source bridge='xenbr0'/> <target dev='vif5.0'/> <mac address='00:16:3e:1d:06:15'/> <script path='vif-bridge'/> </interface> - <disk type='file' device='disk'> - <driver name='tap' type='aio'/> - <source file='/xen/rhel5.img'/> - <target dev='xvda' bus='xen'/> - </disk> <input type='mouse' bus='xen'/> <graphics type='vnc' port='-1'/> <console type='pty'> Index: tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml =================================================================== RCS file: /data/cvs/libvirt/tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml,v retrieving revision 1.10 diff -b -u -p -r1.10 sexpr2xml-no-source-cdrom.xml --- tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml 8 May 2008 14:41:56 -0000 1.10 +++ tests/sexpr2xmldata/sexpr2xml-no-source-cdrom.xml 4 Jun 2008 15:08:25 -0000 @@ -20,11 +20,6 @@ <clock offset='utc'/> <devices> <emulator>/usr/lib/xen/bin/qemu-dm</emulator> - <interface type='bridge'> - <source bridge='xenbr0'/> - <target dev='vif6.0'/> - <mac address='00:16:3e:0a:7b:39'/> - </interface> <disk type='block' device='disk'> <driver name='phy'/> <source dev='/dev/sda8'/> @@ -34,6 +29,11 @@ <target dev='hdc' bus='ide'/> <readonly/> </disk> + <interface type='bridge'> + <source bridge='xenbr0'/> + <target dev='vif6.0'/> + <mac address='00:16:3e:0a:7b:39'/> + </interface> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1'/> <serial type='pty'>
I don't understand why those 2 are changed in this patch. Daniel -- Red Hat Virtualization group http://redhat.com/virtualization/ Daniel Veillard | virtualization library http://libvirt.org/ veillard@redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/ http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

On Thu, Jun 05, 2008 at 08:38:15AM -0400, Daniel Veillard wrote:
hum, we should add a flags extra data. And based on some IRC discussion you already have an use for this.
Thanks - I really need this so I'll commit it, with an extra (unused) flags parameter.
Once you have commited the revised version of the API it woudl be nice to not wait too much for the remote support if possible.
Sure.
I don't understand why those 2 are changed in this patch.
The code changes the order in which disks & network interfaces are processed, in the Xen code that turns sexprs into XML. The disks are now always listed first, whereas before disks and networks were listed in whatever order they happened to appear in the sexpr. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Attached is an updated patch. The changes are: - updated to latest CVS - run make check / syntax-check - remove virsh subcommand (as per Dan's suggestion - see below) - some more things that Dan pointed out - see below ... Index: src/xend_internal.c =================================================================== ... + data.path = path; + data.ok = 0; + + if (xend_parse_sexp_blockdevs (domain->conn, root, + priv->xendConfigVersion, + check_path, &data) == -1) + return -1; + + if (!data.ok) { + virXendError (domain->conn, VIR_ERR_INVALID_ARG, + _("invalid path")); + return -1; + } + + /* The path is correct, now try to open it and get its size. */ + fd = open (path, O_RDONLY); + if (fd == -1 || fstat (fd, &statbuf) == -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + } + + /* Seek and read. */ + /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should + * be 64 bits on all platforms. + */ + if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || + saferead (fd, buffer, size) == (ssize_t) -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + }
Hi Rich, Sorry it took so long. This all looks fine. The only suggestion I can make is to include the "path" in the three diagnostics above. I imagine it might otherwise be hard to understand what the diagnostic is talking about otherwise.

On Fri, Jun 06, 2008 at 05:01:20PM +0200, Jim Meyering wrote:
"Richard W.M. Jones" <rjones@redhat.com> wrote:
Attached is an updated patch. The changes are: - updated to latest CVS - run make check / syntax-check - remove virsh subcommand (as per Dan's suggestion - see below) - some more things that Dan pointed out - see below ... Index: src/xend_internal.c =================================================================== ... + data.path = path; + data.ok = 0; + + if (xend_parse_sexp_blockdevs (domain->conn, root, + priv->xendConfigVersion, + check_path, &data) == -1) + return -1; + + if (!data.ok) { + virXendError (domain->conn, VIR_ERR_INVALID_ARG, + _("invalid path")); + return -1; + } + + /* The path is correct, now try to open it and get its size. */ + fd = open (path, O_RDONLY); + if (fd == -1 || fstat (fd, &statbuf) == -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + } + + /* Seek and read. */ + /* NB. Because we configure with AC_SYS_LARGEFILE, off_t should + * be 64 bits on all platforms. + */ + if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || + saferead (fd, buffer, size) == (ssize_t) -1) { + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + goto done; + }
Hi Rich,
Sorry it took so long.
This all looks fine. The only suggestion I can make is to include the "path" in the three diagnostics above. I imagine it might otherwise be hard to understand what the diagnostic is talking about otherwise.
Suggested patch attached. It seems a little bit perverse to have to put gettext around "%s: %s" but that's what make syntax-check wants. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top

"Richard W.M. Jones" <rjones@redhat.com> wrote: ...
It seems a little bit perverse to have to put gettext around "%s: %s" but that's what make syntax-check wants.
That is a relatively naive rule that was good enough for the existing uses. It shouldn't be hard to make it grant exceptions like that. I'll take a look.

"Richard W.M. Jones" <rjones@redhat.com> wrote:
Suggested patch attached.
Looks fine. Now that you've added the format string argument, we can give diagnostics that are more useful not just to users, but also to those who end up debugging things.
It seems a little bit perverse to have to put gettext around "%s: %s" but that's what make syntax-check wants. ... On second though, you can think of this as encouragement to avoid format strings with no translatable text.
I've found that bare "filename: strerror (errno)" diagnostics pose enough of a problem from the superficial "where did that come from" perspective that I try hard now always to provide a little more information (and thus something that is translatable). Of course, the minimal diagnostics are often hard to understand, too. I suspect that users don't mind getting that little bit of added info...
Index: src/xend_internal.c =================================================================== ... @@ -3925,12 +3937,14 @@ xenDaemonDomainMigratePrepare (virConnec if (uri_in == NULL) { r = gethostname (hostname, HOST_NAME_MAX+1); if (r == -1) { - virXendError (dconn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + virXendError (dconn, VIR_ERR_SYSTEM_ERROR, + "%s", strerror (errno));
maybe give more info: "gethostname failed: %s", strerror (errno));
return -1; } *uri_out = strdup (hostname); if (*uri_out == NULL) { - virXendError (dconn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + virXendError (dconn, VIR_ERR_SYSTEM_ERROR, + "%s", strerror (errno));
likewise, (but I don't like this one, but maybe better than nothing): "hostname strdup failed: %s", strerror (errno));
return -1; } } @@ -4575,14 +4589,15 @@ xenDaemonDomainBlockPeek (virDomainPtr d
if (!data.ok) { virXendError (domain->conn, VIR_ERR_INVALID_ARG, - _("invalid path")); + _("%s: invalid path"), path); return -1; }
/* The path is correct, now try to open it and get its size. */ fd = open (path, O_RDONLY); if (fd == -1) { - virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, + _("%s: %s"), path, strerror (errno));
For the above, how about _("%s: failed to open for reading: %s"), path, strerror (errno)); and for the one below: _("%s: lseek failed: %s"), path, strerror (errno));
goto done; }
@@ -4592,7 +4607,8 @@ xenDaemonDomainBlockPeek (virDomainPtr d */ if (lseek (fd, offset, SEEK_SET) == (off_t) -1 || saferead (fd, buffer, size) == (ssize_t) -1) { - virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, strerror (errno)); + virXendError (domain->conn, VIR_ERR_SYSTEM_ERROR, + _("%s: %s"), path, strerror (errno));

OK how about this one ... Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
participants (4)
-
Daniel P. Berrange
-
Daniel Veillard
-
Jim Meyering
-
Richard W.M. Jones