[PATCH v3 RESEND] direct, fish: add blocksize as optional argument for launch command
by Tuan Hoang
Allow `launch` call to accept an optional argument, called `blocksize`.
Example:
$ guestfish --listen -a raw.img
$ guestfish --remote -- launch blocksize:4096
The actual qemu command is:
[...]
-device virtio-scsi-ccw,id=scsi
-drive file=raw.img,cache=writeback,id=hd0,if=none
-device scsi-hd,drive=hd0,physical_block_size=4096,logical_block_size=4096
[...]
Signed-off-by: Tuan Hoang <tmhoang(a)linux.ibm.com>
---
generator/actions_core.ml | 18 ++++++++++++++++--
lib/guestfs-internal.h | 3 +++
lib/launch-direct.c | 6 ++++++
lib/launch.c | 12 +++++++++++-
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 7b6568b..0026650 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -26,7 +26,7 @@ open Types
let non_daemon_functions = [
{ defaults with
name = "launch"; added = (0, 0, 3);
- style = RErr, [], [];
+ style = RErr, [], [OInt "blocksize"];
fish_alias = ["run"]; progress = true; config_only = true;
shortdesc = "launch the backend";
longdesc = "\
@@ -36,7 +36,21 @@ You should call this after configuring the handle
Do not call C<guestfs_launch> twice on the same handle. Although
it will not give an error (for historical reasons), the precise
behaviour when you do this is not well defined. Handles are
-very cheap to create, so create a new one for each launch." };
+very cheap to create, so create a new one for each launch.
+
+The optional arguments are:
+
+=over 4
+
+=item C<blocksize>
+
+If provided, the call will add C<physical_block_size=\"blocksize\"> and
+C<logical_block_size=\"blocksize\"> to qemu's C<-device> directive. The blocksize
+must be a power of 2 between 512 and 32768, or else it will be ignored.
+
+The default is none, and qemu would assume a blocksize of 512.
+
+=back" };
{ defaults with
name = "add_drive_ro"; added = (1, 0, 38);
diff --git a/lib/guestfs-internal.h b/lib/guestfs-internal.h
index 75b8a5c..090ba58 100644
--- a/lib/guestfs-internal.h
+++ b/lib/guestfs-internal.h
@@ -513,6 +513,9 @@ struct guestfs_h {
/* Used by lib/info.c. -1 = not tested or error; else 0 or 1. */
int qemu_img_supports_U_option;
+
+ /* Used by guestfish's launch call */
+ int blocksize;
};
/**
diff --git a/lib/launch-direct.c b/lib/launch-direct.c
index ee2dcb8..54cd8c6 100644
--- a/lib/launch-direct.c
+++ b/lib/launch-direct.c
@@ -315,6 +315,12 @@ add_drive (guestfs_h *g, struct backend_direct_data *data,
start_list ("-device") {
append_list ("scsi-hd");
append_list_format ("drive=hd%zu", i);
+ if (g->blocksize >= 512 && g->blocksize <= 32768
+ && (g->blocksize & (g->blocksize-1)) == 0)
+ {
+ append_list_format ("physical_block_size=%d", g->blocksize);
+ append_list_format ("logical_block_size=%d", g->blocksize);
+ }
if (drv->disk_label)
append_list_format ("serial=%s", drv->disk_label);
} end_list ();
diff --git a/lib/launch.c b/lib/launch.c
index eb7f85c..f56e389 100644
--- a/lib/launch.c
+++ b/lib/launch.c
@@ -54,7 +54,7 @@ static struct backend {
} *backends = NULL;
int
-guestfs_impl_launch (guestfs_h *g)
+guestfs_impl_launch (guestfs_h *g, const struct guestfs_launch_argv *optargs)
{
int r;
@@ -85,6 +85,16 @@ guestfs_impl_launch (guestfs_h *g)
if (guestfs_int_lazy_make_tmpdir (g) == -1)
return -1;
+ /* Add the blocksize. */
+ if (optargs->blocksize >= 512 && optargs->blocksize <= 32768
+ && (optargs->blocksize & (optargs->blocksize-1)) == 0) {
+ g->blocksize = optargs->blocksize;
+ debug (g, "using blocksize of %d", g->blocksize);
+ }
+ else {
+ debug (g, _("blocksize must be a power of 2 between 512 and 32768"));
+ }
+
/* Some common debugging information. */
if (g->verbose) {
CLEANUP_FREE_VERSION struct guestfs_version *v =
--
2.21.0
5 years, 1 month
[PATCH v2 RESEND] direct, fish: add command launch_blocksize
by Tuan Hoang
Add a new launch command for direct backend, which allows specifying the
blocksize to the disks. The name is `launch_blocksize`, accompanied alias is
`run-blocksize`.
Example:
$ guestfish --listen -a raw.img
$ guestfish --remote -- launch_blocksize 4096
The actual qemu command is:
[...]
-device virtio-scsi-ccw,id=scsi
-drive file=raw.img,cache=writeback,id=hd0,if=none
-device scsi-hd,drive=hd0,physical_block_size=4096,logical_block_size=4096
[...]
Ideally it would be better to invoke optional option to `launch` command
like:
$ guestfish --remote -- launch --blocksize 4096
Signed-off-by: Tuan Hoang <tmhoang(a)linux.ibm.com>
---
generator/actions_core.ml | 11 +++++++++++
lib/guestfs-internal.h | 3 +++
lib/launch-direct.c | 6 ++++++
lib/launch.c | 14 ++++++++++++++
4 files changed, 34 insertions(+)
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index 7b6568b..cfe735a 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -38,6 +38,17 @@ it will not give an error (for historical reasons), the precise
behaviour when you do this is not well defined. Handles are
very cheap to create, so create a new one for each launch." };
+ { defaults with
+ name = "launch_blocksize"; added = (1, 40, 2);
+ style = RErr, [Int "blocksize"], [];
+ fish_alias = ["run-blocksize"]; progress = true; config_only = true;
+ shortdesc = "launch the backend with blocksize for disks";
+ longdesc = "\
+Similar to \"launch\" call, but requires an integer as blocksize for disks.
+
+A call of \"launch_blocksize 512\" is equivalent of \"launch\" since the
+default blocksize for qemu is 512." };
+
{ defaults with
name = "add_drive_ro"; added = (1, 0, 38);
style = RErr, [String (PlainString, "filename")], [];
diff --git a/lib/guestfs-internal.h b/lib/guestfs-internal.h
index 75b8a5c..e9b7057 100644
--- a/lib/guestfs-internal.h
+++ b/lib/guestfs-internal.h
@@ -513,6 +513,9 @@ struct guestfs_h {
/* Used by lib/info.c. -1 = not tested or error; else 0 or 1. */
int qemu_img_supports_U_option;
+
+ /* Used by guestfish's launch_blocksize call */
+ int blocksize;
};
/**
diff --git a/lib/launch-direct.c b/lib/launch-direct.c
index ee2dcb8..54cd8c6 100644
--- a/lib/launch-direct.c
+++ b/lib/launch-direct.c
@@ -315,6 +315,12 @@ add_drive (guestfs_h *g, struct backend_direct_data *data,
start_list ("-device") {
append_list ("scsi-hd");
append_list_format ("drive=hd%zu", i);
+ if (g->blocksize >= 512 && g->blocksize <= 32768
+ && (g->blocksize & (g->blocksize-1)) == 0)
+ {
+ append_list_format ("physical_block_size=%d", g->blocksize);
+ append_list_format ("logical_block_size=%d", g->blocksize);
+ }
if (drv->disk_label)
append_list_format ("serial=%s", drv->disk_label);
} end_list ();
diff --git a/lib/launch.c b/lib/launch.c
index eb7f85c..8edf7b1 100644
--- a/lib/launch.c
+++ b/lib/launch.c
@@ -53,6 +53,20 @@ static struct backend {
const struct backend_ops *ops;
} *backends = NULL;
+int
+guestfs_impl_launch_blocksize (guestfs_h *g, int blocksize)
+{
+ if (blocksize >= 512 && blocksize <= 32768
+ && (blocksize & (blocksize-1)) == 0) {
+ g->blocksize = blocksize;
+ return guestfs_impl_launch (g);
+ }
+ else {
+ error (g, _("blocksize must be a power of 2 between 512 and 32768"));
+ return -1;
+ }
+}
+
int
guestfs_impl_launch (guestfs_h *g)
{
--
2.21.0
5 years, 1 month
[PATCH] v2v: Optimize convert for images with small holes
by Nir Soffer
"qemu-img convert" detects zeroes in allocated areas and punch holes in
the destination image. This may save space on the destination image, but
slows down conversion when using outputs such as rhv-upload, which have
very large overhead per requests.
Using the -S flag, we can treat small areas filled with zeroes as data,
limiting the number of requests, and speeding the operation.
Here is an example converting Fedora 30 image:
$ virt-builder fedora-30 -o src.img
...
$ qemu-img map -f raw --output json src.img | wc -l
213
$ qemu-img convert -f raw -O raw -t none -T none src.img dst.img
$ qemu-img map -f raw --output json dst.img | wc -l
1443
$ ls -lhs *.img
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:48 dst.img
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:46 src.img
Qemu did 1443 writes instead of 213 (5.8X). Lets repeat this conversion
with the -S option:
$ qemu-img convert -f raw -O raw -t none -T none -S 64k src.img dst.img
$ qemu-img map -f raw --output json dst.img | wc -l
213
$ ls -lhs *.img
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:48 dst.img
1.2G -rw-r--r--. 1 nsoffer nsoffer 6.0G Nov 1 21:46 src.img
Picking a good value for -S is not easy. Testing show that 64k is best
value for this test image for limiting the number of requests:
$ for size in 4k 8k 16k 32k 64k; do \
printf "%5s: " $size; \
qemu-img convert -f raw -O raw -t none -T none -S $size src.img dst.img; \
qemu-img map -f raw --output json dst.img | wc -l; \
done
4k: 1443
8k: 731
16k: 521
32k: 387
64k: 213
We need more testing with oVirt to measure the performance improvement
and pick a good value. This should probably be an option, but lets start
with a minimal change.
---
Untested. I cannot build virt-v2v on Fedora 29 since libguestfs 1.41.5
is required but not available. I can also not build libguestfs from git
becuase setting up common submodule in ./autogen.sh fails.
v2v/v2v.ml | 1 +
1 file changed, 1 insertion(+)
diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 4655b883..03590c9e 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -741,6 +741,7 @@ and copy_targets cmdline targets input output =
(if not (quiet ()) then [ "-p" ] else []) @
[ "-n"; "-f"; "qcow2"; "-O"; t.target_format ] @
(if cmdline.compressed then [ "-c" ] else []) @
+ [ "-S"; "64k" ] @
[ overlay_file; filename ] in
let start_time = gettimeofday () in
if run_command cmd <> 0 then
--
2.20.1
5 years, 1 month
Planning for libnbd 1.2
by Richard W.M. Jones
[I'm quite convinced I wrote this down in an email before, but I
cannot find it. Maybe we only talked about it on IRC? Anyway, my
apologies if this is a repeat ...]
We're planning to add libnbd to RHEL & CentOS 8.x, likely in
RHEL AV 8.2 and CentOS 8.2 or 8.3. It would be nice to get some of
the new features added upstream since 1.0 was released, such as:
- fast zeroing
- ability to negotiate SRs, handshake flags
- connect to systemd socket activated servers like qemu-nbd
- vsock support
- NBD URI filtering
- nbdfuse
- much improved documentation
- reproducible builds
Upstream-only changes, but still useful:
- fuzzing support
- common nbd-protocol.h
- wider test coverage, particularly TLS interop
- more examples
So I think in the next week or two we could do a libnbd 1.2 (stable)
release. The main task is to review the new APIs and make sure
they're something that we wish to support long-term:
https://github.com/libguestfs/libnbd/blob/d94e69f685b360597df0a3551fe2744...
For reference also, 1.0 was released at the end of August, so this
would mean 1.2 releasing about 2½ - 3 months after.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/
5 years, 1 month
supermin: failed to find a suitable kernel
by Klaas Schulze-Dieckhoff
Hi all
I am trying to run the dockerized version of linaro lava. Unfortunately it is not possible to start libguetsfs inside one of the containers.
My settings are: Ubuntu Server 18.04.3, Docker version 18.09.7 running a Debian:stretch based contianer
Running libguestfs-test-tool gives me the following output:
root@e91c89e0874d:/# libguestfs-test-tool
************************************************************
* IMPORTANT NOTICE
*
* When reporting bugs, include the COMPLETE, UNEDITED
* output below in your bug report.
*
************************************************************
libguestfs: trace: set_verbose true
libguestfs: trace: set_verbose = 0
libguestfs: trace: set_backend "direct"
libguestfs: trace: set_backend = 0
libguestfs: trace: set_verbose true
libguestfs: trace: set_verbose = 0
LIBGUESTFS_BACKEND=direct
LIBGUESTFS_TRACE=1
LIBGUESTFS_DEBUG=1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SELinux: sh: 1: getenforce: not found
libguestfs: trace: add_drive_scratch 104857600
libguestfs: trace: get_tmpdir
libguestfs: trace: get_tmpdir = "/tmp"
libguestfs: trace: disk_create "/tmp/libguestfspqGts5/scratch.1" "raw" 104857600
libguestfs: trace: disk_create = 0
libguestfs: trace: add_drive "/tmp/libguestfspqGts5/scratch.1" "format:raw" "cachemode:unsafe"
libguestfs: trace: add_drive = 0
libguestfs: trace: add_drive_scratch = 0
libguestfs: trace: get_append
libguestfs: trace: get_append = "NULL"
guestfs_get_append: (null)
libguestfs: trace: get_autosync
libguestfs: trace: get_autosync = 1
guestfs_get_autosync: 1
libguestfs: trace: get_backend
libguestfs: trace: get_backend = "direct"
guestfs_get_backend: direct
libguestfs: trace: get_backend_settings
libguestfs: trace: get_backend_settings = []
guestfs_get_backend_settings: []
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/var/tmp"
guestfs_get_cachedir: /var/tmp
libguestfs: trace: get_direct
libguestfs: trace: get_direct = 0
guestfs_get_direct: 0
libguestfs: trace: get_hv
libguestfs: trace: get_hv = "/usr/bin/qemu-system-x86_64"
guestfs_get_hv: /usr/bin/qemu-system-x86_64
libguestfs: trace: get_memsize
libguestfs: trace: get_memsize = 500
guestfs_get_memsize: 500
libguestfs: trace: get_network
libguestfs: trace: get_network = 0
guestfs_get_network: 0
libguestfs: trace: get_path
libguestfs: trace: get_path = "/usr/lib/x86_64-linux-gnu/guestfs"
guestfs_get_path: /usr/lib/x86_64-linux-gnu/guestfs
libguestfs: trace: get_pgroup
libguestfs: trace: get_pgroup = 0
guestfs_get_pgroup: 0
libguestfs: trace: get_program
libguestfs: trace: get_program = "libguestfs-test-tool"
guestfs_get_program: libguestfs-test-tool
libguestfs: trace: get_recovery_proc
libguestfs: trace: get_recovery_proc = 1
guestfs_get_recovery_proc: 1
libguestfs: trace: get_smp
libguestfs: trace: get_smp = 1
guestfs_get_smp: 1
libguestfs: trace: get_sockdir
libguestfs: trace: get_sockdir = "/tmp"
guestfs_get_sockdir: /tmp
libguestfs: trace: get_tmpdir
libguestfs: trace: get_tmpdir = "/tmp"
guestfs_get_tmpdir: /tmp
libguestfs: trace: get_trace
libguestfs: trace: get_trace = 1
guestfs_get_trace: 1
libguestfs: trace: get_verbose
libguestfs: trace: get_verbose = 1
guestfs_get_verbose: 1
host_cpu: x86_64
Launching appliance, timeout set to 600 seconds.
libguestfs: trace: launch
libguestfs: trace: version
libguestfs: trace: version = <struct guestfs_version = major: 1, minor: 34, release: 6, extra: , >
libguestfs: trace: get_backend
libguestfs: trace: get_backend = "direct"
libguestfs: launch: program=libguestfs-test-tool
libguestfs: launch: version=1.34.6
libguestfs: launch: backend registered: unix
libguestfs: launch: backend registered: uml
libguestfs: launch: backend registered: libvirt
libguestfs: launch: backend registered: direct
libguestfs: launch: backend=direct
libguestfs: launch: tmpdir=/tmp/libguestfspqGts5
libguestfs: launch: umask=0022
libguestfs: launch: euid=0
libguestfs: trace: get_backend_setting "force_tcg"
libguestfs: trace: get_backend_setting = NULL (error)
libguestfs: trace: get_cachedir
libguestfs: trace: get_cachedir = "/var/tmp"
libguestfs: begin building supermin appliance
libguestfs: run supermin
libguestfs: command: run: /usr/bin/supermin
libguestfs: command: run: \ --build
libguestfs: command: run: \ --verbose
libguestfs: command: run: \ --if-newer
libguestfs: command: run: \ --lock /var/tmp/.guestfs-0/lock
libguestfs: command: run: \ --copy-kernel
libguestfs: command: run: \ -f ext2
libguestfs: command: run: \ --host-cpu x86_64
libguestfs: command: run: \ /usr/lib/x86_64-linux-gnu/guestfs/supermin.d
libguestfs: command: run: \ -o /var/tmp/.guestfs-0/appliance.d
supermin: version: 5.1.17
supermin: package handler: debian/dpkg
supermin: acquiring lock on /var/tmp/.guestfs-0/lock
supermin: build: /usr/lib/x86_64-linux-gnu/guestfs/supermin.d
supermin: reading the supermin appliance
supermin: build: visiting /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/base.tar.gz type gzip base image (tar)
supermin: build: visiting /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/daemon.tar.gz type gzip base image (tar)
supermin: build: visiting /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/excludefiles type uncompressed excludefiles
supermin: build: visiting /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/hostfiles type uncompressed hostfiles
supermin: build: visiting /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/init.tar.gz type gzip base image (tar)
supermin: build: visiting /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/packages type uncompressed packages
supermin: build: visiting /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/udev-rules.tar.gz type gzip base image (tar)
supermin: mapping package names to installed packages
supermin: resolving full list of package dependencies
supermin: build: 188 packages, including dependencies
supermin: build: 10647 files
supermin: build: 6483 files, after matching excludefiles
supermin: build: 6486 files, after adding hostfiles
supermin: build: 6486 files, after removing unreadable files
supermin: build: 6489 files, after munging
supermin: failed to find a suitable kernel (host_cpu=x86_64).
I looked for kernels in /boot and modules in /lib/modules.
If this is a Xen guest, and you only have Xen domU kernels
installed, try installing a fullvirt kernel (only for
supermin use, you shouldn't boot the Xen guest with it).
libguestfs: error: /usr/bin/supermin exited with error status 1, see debug messages above
libguestfs: trace: launch = -1 (error)
libguestfs: trace: close
libguestfs: closing guestfs handle 0x5627c93af260 (state 0)
libguestfs: command: run: rm
libguestfs: command: run: \ -rf /tmp/libguestfspqGts5
Can anybody point me the right direction to fix this?
Thanks a lot
Klaas
Geschäftsführer: Christoph Ostermann (CEO), Oliver Koch, Steffen Schneider, Hermann Schweizer, Tim Ulbricht.
Amtsgericht Kempten/Allgäu, Registernummer: 10655, Steuernummer 127/137/50792, USt.-IdNr. DE272208908
5 years, 1 month
installing supermin on debian10
by Keresztes Péter-Zoltán
Hello
I am trying to install supermin on debian 10 (buster) and I am getting the following error:
checking /usr/sbin/mke2fs -t or -T... -t
checking for EXT2FS... no
configure: error: in `/root/supermin-5.1.16':
configure: error: The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config.
Alternatively, you may set the environment variables EXT2FS_CFLAGS
and EXT2FS_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See `config.log' for more details
Note that I have installed all the required dependency packages which I could find in the README.
Can anyone help making this work?
Regards,
Peter
5 years, 1 month
Re: [Libguestfs] supermin: failed to find a suitable kernel
by Tomáš Golembiovský
On Mon, Nov 04, 2019 at 08:26:08PM +0000, Klaas Schulze-Dieckhoff wrote:
> As requested this is the output inside my container:
> root@ead989650980:/# ls /boot
> androidboot efi grubinitrd.img-core initrd.img-core-0.7.43+ppa27 uboot
> root@ead989650980:/# ls /lib/modules
> 4.15.0-66-generic
>
> I know, that there is no kernel inside /boot, but to my understanding this is a normal behavior of docker and I can not just install a kernel inside the container.
>
You can either download fixed appliance from [1] or build your own fixed
appliance on the host using libguestfs-make-fixed-appliance [2]. You can
then provide the same fixed appliance to all your containers as
a volume. Set LIBGUESTFS_PATH env. variable to configure the location.
Tomas
[1] http://download.libguestfs.org/binaries/appliance/
[2] http://libguestfs.org/libguestfs-make-fixed-appliance.1.html
> /dev/kvm is already mounted inside this container.
>
> Thanks
> Klaas
>
> > -----Ursprüngliche Nachricht-----
> > Von: Tomáš Golembiovský <tgolembi(a)redhat.com>
> > Gesendet: Montag, 4. November 2019 18:11
> > An: Klaas Schulze-Dieckhoff <K.Schulze-Dieckhoff(a)sonnen.de>
> > Cc: libguestfs(a)redhat.com
> > Betreff: Re: [Libguestfs] supermin: failed to find a suitable kernel
> >
> > What is the content of /boot and /lib/modules inside the container?
> >
> > Also you may want to expose /dev/kvm into the container to get proper
> > virtualization. Otherwise you're stuck with software emulation (TCG) which is
> > much slower.
> >
> > Tomas
> >
> > On Sat, Nov 02, 2019 at 09:36:21AM +0000, Klaas Schulze-Dieckhoff wrote:
> > > Hi all
> > >
> > > I am trying to run the dockerized version of linaro lava. Unfortunately it is
> > not possible to start libguetsfs inside one of the containers.
> > > My settings are: Ubuntu Server 18.04.3, Docker version 18.09.7 running
> > > a Debian:stretch based contianer
> > >
> > > Running libguestfs-test-tool gives me the following output:
> > >
> > >
> > > root@e91c89e0874d:/# libguestfs-test-tool
> > >
> > **********************************************************
> > **
> > > * IMPORTANT NOTICE
> > > *
> > > * When reporting bugs, include the COMPLETE, UNEDITED
> > > * output below in your bug report.
> > > *
> > >
> > **********************************************************
> > **
> > > libguestfs: trace: set_verbose true
> > > libguestfs: trace: set_verbose = 0
> > > libguestfs: trace: set_backend "direct"
> > > libguestfs: trace: set_backend = 0
> > > libguestfs: trace: set_verbose true
> > > libguestfs: trace: set_verbose = 0
> > > LIBGUESTFS_BACKEND=direct
> > > LIBGUESTFS_TRACE=1
> > > LIBGUESTFS_DEBUG=1
> > > PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
> > > SELinux: sh: 1: getenforce: not found
> > > libguestfs: trace: add_drive_scratch 104857600
> > > libguestfs: trace: get_tmpdir
> > > libguestfs: trace: get_tmpdir = "/tmp"
> > > libguestfs: trace: disk_create "/tmp/libguestfspqGts5/scratch.1" "raw"
> > > 104857600
> > > libguestfs: trace: disk_create = 0
> > > libguestfs: trace: add_drive "/tmp/libguestfspqGts5/scratch.1"
> > "format:raw" "cachemode:unsafe"
> > > libguestfs: trace: add_drive = 0
> > > libguestfs: trace: add_drive_scratch = 0
> > > libguestfs: trace: get_append
> > > libguestfs: trace: get_append = "NULL"
> > > guestfs_get_append: (null)
> > > libguestfs: trace: get_autosync
> > > libguestfs: trace: get_autosync = 1
> > > guestfs_get_autosync: 1
> > > libguestfs: trace: get_backend
> > > libguestfs: trace: get_backend = "direct"
> > > guestfs_get_backend: direct
> > > libguestfs: trace: get_backend_settings
> > > libguestfs: trace: get_backend_settings = []
> > > guestfs_get_backend_settings: []
> > > libguestfs: trace: get_cachedir
> > > libguestfs: trace: get_cachedir = "/var/tmp"
> > > guestfs_get_cachedir: /var/tmp
> > > libguestfs: trace: get_direct
> > > libguestfs: trace: get_direct = 0
> > > guestfs_get_direct: 0
> > > libguestfs: trace: get_hv
> > > libguestfs: trace: get_hv = "/usr/bin/qemu-system-x86_64"
> > > guestfs_get_hv: /usr/bin/qemu-system-x86_64
> > > libguestfs: trace: get_memsize
> > > libguestfs: trace: get_memsize = 500
> > > guestfs_get_memsize: 500
> > > libguestfs: trace: get_network
> > > libguestfs: trace: get_network = 0
> > > guestfs_get_network: 0
> > > libguestfs: trace: get_path
> > > libguestfs: trace: get_path = "/usr/lib/x86_64-linux-gnu/guestfs"
> > > guestfs_get_path: /usr/lib/x86_64-linux-gnu/guestfs
> > > libguestfs: trace: get_pgroup
> > > libguestfs: trace: get_pgroup = 0
> > > guestfs_get_pgroup: 0
> > > libguestfs: trace: get_program
> > > libguestfs: trace: get_program = "libguestfs-test-tool"
> > > guestfs_get_program: libguestfs-test-tool
> > > libguestfs: trace: get_recovery_proc
> > > libguestfs: trace: get_recovery_proc = 1
> > > guestfs_get_recovery_proc: 1
> > > libguestfs: trace: get_smp
> > > libguestfs: trace: get_smp = 1
> > > guestfs_get_smp: 1
> > > libguestfs: trace: get_sockdir
> > > libguestfs: trace: get_sockdir = "/tmp"
> > > guestfs_get_sockdir: /tmp
> > > libguestfs: trace: get_tmpdir
> > > libguestfs: trace: get_tmpdir = "/tmp"
> > > guestfs_get_tmpdir: /tmp
> > > libguestfs: trace: get_trace
> > > libguestfs: trace: get_trace = 1
> > > guestfs_get_trace: 1
> > > libguestfs: trace: get_verbose
> > > libguestfs: trace: get_verbose = 1
> > > guestfs_get_verbose: 1
> > > host_cpu: x86_64
> > > Launching appliance, timeout set to 600 seconds.
> > > libguestfs: trace: launch
> > > libguestfs: trace: version
> > > libguestfs: trace: version = <struct guestfs_version = major: 1,
> > > minor: 34, release: 6, extra: , >
> > > libguestfs: trace: get_backend
> > > libguestfs: trace: get_backend = "direct"
> > > libguestfs: launch: program=libguestfs-test-tool
> > > libguestfs: launch: version=1.34.6
> > > libguestfs: launch: backend registered: unix
> > > libguestfs: launch: backend registered: uml
> > > libguestfs: launch: backend registered: libvirt
> > > libguestfs: launch: backend registered: direct
> > > libguestfs: launch: backend=direct
> > > libguestfs: launch: tmpdir=/tmp/libguestfspqGts5
> > > libguestfs: launch: umask=0022
> > > libguestfs: launch: euid=0
> > > libguestfs: trace: get_backend_setting "force_tcg"
> > > libguestfs: trace: get_backend_setting = NULL (error)
> > > libguestfs: trace: get_cachedir
> > > libguestfs: trace: get_cachedir = "/var/tmp"
> > > libguestfs: begin building supermin appliance
> > > libguestfs: run supermin
> > > libguestfs: command: run: /usr/bin/supermin
> > > libguestfs: command: run: \ --build
> > > libguestfs: command: run: \ --verbose
> > > libguestfs: command: run: \ --if-newer
> > > libguestfs: command: run: \ --lock /var/tmp/.guestfs-0/lock
> > > libguestfs: command: run: \ --copy-kernel
> > > libguestfs: command: run: \ -f ext2
> > > libguestfs: command: run: \ --host-cpu x86_64
> > > libguestfs: command: run: \
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d
> > > libguestfs: command: run: \ -o /var/tmp/.guestfs-0/appliance.d
> > > supermin: version: 5.1.17
> > > supermin: package handler: debian/dpkg
> > > supermin: acquiring lock on /var/tmp/.guestfs-0/lock
> > > supermin: build: /usr/lib/x86_64-linux-gnu/guestfs/supermin.d
> > > supermin: reading the supermin appliance
> > > supermin: build: visiting
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/base.tar.gz type gzip
> > > base image (tar)
> > > supermin: build: visiting
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/daemon.tar.gz type gzip
> > > base image (tar)
> > > supermin: build: visiting
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/excludefiles type
> > > uncompressed excludefiles
> > > supermin: build: visiting
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/hostfiles type
> > > uncompressed hostfiles
> > > supermin: build: visiting
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/init.tar.gz type gzip
> > > base image (tar)
> > > supermin: build: visiting
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/packages type
> > > uncompressed packages
> > > supermin: build: visiting
> > > /usr/lib/x86_64-linux-gnu/guestfs/supermin.d/udev-rules.tar.gz type
> > > gzip base image (tar)
> > > supermin: mapping package names to installed packages
> > > supermin: resolving full list of package dependencies
> > > supermin: build: 188 packages, including dependencies
> > > supermin: build: 10647 files
> > > supermin: build: 6483 files, after matching excludefiles
> > > supermin: build: 6486 files, after adding hostfiles
> > > supermin: build: 6486 files, after removing unreadable files
> > > supermin: build: 6489 files, after munging
> > > supermin: failed to find a suitable kernel (host_cpu=x86_64).
> > >
> > > I looked for kernels in /boot and modules in /lib/modules.
> > >
> > > If this is a Xen guest, and you only have Xen domU kernels installed,
> > > try installing a fullvirt kernel (only for supermin use, you shouldn't
> > > boot the Xen guest with it).
> > > libguestfs: error: /usr/bin/supermin exited with error status 1, see
> > > debug messages above
> > > libguestfs: trace: launch = -1 (error)
> > > libguestfs: trace: close
> > > libguestfs: closing guestfs handle 0x5627c93af260 (state 0)
> > > libguestfs: command: run: rm
> > > libguestfs: command: run: \ -rf /tmp/libguestfspqGts5
> > >
> > > Can anybody point me the right direction to fix this?
> > >
> > > Thanks a lot
> > > Klaas
> > > Geschäftsführer: Christoph Ostermann (CEO), Oliver Koch, Steffen
> > Schneider, Hermann Schweizer, Tim Ulbricht.
> > > Amtsgericht Kempten/Allgäu, Registernummer: 10655, Steuernummer
> > > 127/137/50792, USt.-IdNr. DE272208908
> > >
> > > _______________________________________________
> > > Libguestfs mailing list
> > > Libguestfs(a)redhat.com
> > > https://www.redhat.com/mailman/listinfo/libguestfs
> >
> > --
> > Tomáš Golembiovský <tgolembi(a)redhat.com>
> Geschäftsführer: Christoph Ostermann (CEO), Oliver Koch, Steffen Schneider, Hermann Schweizer, Tim Ulbricht.
> Amtsgericht Kempten/Allgäu, Registernummer: 10655, Steuernummer 127/137/50792, USt.-IdNr. DE272208908
--
Tomáš Golembiovský <tgolembi(a)redhat.com>
5 years, 1 month
[PATCH nbdkit] server: Use GCC hints to move debug and error handling code out of hot paths.
by Richard W.M. Jones
For GCC only, define unlikely() macro. Use it on error paths to move
code out of the hot path.
In the server only, use the debug() macro (don't call nbdkit_debug
directly). This macro checks the verbose flag and moves the call to
nbdkit_debug out of the hot path.
---
server/connections.c | 11 ++++++-----
server/internal.h | 17 ++++++++++++++++-
server/plugins.c | 2 +-
server/protocol.c | 4 ++--
server/sockets.c | 4 ++--
5 files changed, 27 insertions(+), 11 deletions(-)
diff --git a/server/connections.c b/server/connections.c
index c55d381..95d8296 100644
--- a/server/connections.c
+++ b/server/connections.c
@@ -97,7 +97,7 @@ connection_set_status (struct connection *conn, int value)
assert (conn->status_pipe[1] >= 0);
if (write (conn->status_pipe[1], &c, 1) != 1 && errno != EAGAIN)
- nbdkit_debug ("failed to notify pipe-to-self: %m");
+ debug ("failed to notify pipe-to-self: %m");
}
conn->status = value;
}
@@ -176,7 +176,7 @@ _handle_single_connection (int sockin, int sockout)
debug ("handshake complete, processing requests with %d threads",
nworkers);
workers = calloc (nworkers, sizeof *workers);
- if (!workers) {
+ if (unlikely (!workers)) {
perror ("malloc");
goto done;
}
@@ -185,12 +185,13 @@ _handle_single_connection (int sockin, int sockout)
struct worker_data *worker = malloc (sizeof *worker);
int err;
- if (!worker) {
+ if (unlikely (!worker)) {
perror ("malloc");
connection_set_status (conn, -1);
goto wait;
}
- if (asprintf (&worker->name, "%s.%d", plugin_name, nworkers) < 0) {
+ if (unlikely (asprintf (&worker->name, "%s.%d", plugin_name, nworkers)
+ < 0)) {
perror ("asprintf");
connection_set_status (conn, -1);
free (worker);
@@ -199,7 +200,7 @@ _handle_single_connection (int sockin, int sockout)
worker->conn = conn;
err = pthread_create (&workers[nworkers], NULL, connection_worker,
worker);
- if (err) {
+ if (unlikely (err)) {
errno = err;
perror ("pthread_create");
connection_set_status (conn, -1);
diff --git a/server/internal.h b/server/internal.h
index 5e11e1a..7e0c375 100644
--- a/server/internal.h
+++ b/server/internal.h
@@ -45,6 +45,17 @@
#include "cleanup.h"
#include "nbd-protocol.h"
+/* Define unlikely macro, but only for GCC. These are used to move
+ * debug and error handling code out of hot paths.
+ */
+#if defined(__GNUC__)
+#define unlikely(x) __builtin_expect (!!(x), 0)
+#define if_verbose if (unlikely (verbose))
+#else
+#define unlikely(x) (x)
+#define if_verbose if (verbose)
+#endif
+
#ifdef __APPLE__
#define UNIX_PATH_MAX 104
#else
@@ -262,7 +273,11 @@ extern int crypto_negotiate_tls (struct connection *conn,
__attribute__((__nonnull__ (1)));
/* debug.c */
-#define debug nbdkit_debug
+#define debug(fs, ...) \
+ do { \
+ if_verbose \
+ nbdkit_debug ((fs), ##__VA_ARGS__); \
+ } while (0)
/* log-*.c */
#if !HAVE_VFPRINTF_PERCENT_M
diff --git a/server/plugins.c b/server/plugins.c
index 87daaf2..65f6817 100644
--- a/server/plugins.c
+++ b/server/plugins.c
@@ -71,7 +71,7 @@ plugin_thread_model (struct backend *b)
#if !(defined SOCK_CLOEXEC && defined HAVE_MKOSTEMP && defined HAVE_PIPE2 && \
defined HAVE_ACCEPT4)
if (thread_model > NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS) {
- nbdkit_debug ("system lacks atomic CLOEXEC, serializing to avoid fd leaks");
+ debug ("system lacks atomic CLOEXEC, serializing to avoid fd leaks");
thread_model = NBDKIT_THREAD_MODEL_SERIALIZE_ALL_REQUESTS;
}
#endif
diff --git a/server/protocol.c b/server/protocol.c
index 89fbdfa..f6ea35c 100644
--- a/server/protocol.c
+++ b/server/protocol.c
@@ -508,8 +508,8 @@ extents_to_block_descriptors (struct nbdkit_extents *extents,
#if 0
for (i = 0; i < *nr_blocks; ++i)
- nbdkit_debug ("block status: sending block %" PRIu32 " type %" PRIu32,
- blocks[i].length, blocks[i].status_flags);
+ debug ("block status: sending block %" PRIu32 " type %" PRIu32,
+ blocks[i].length, blocks[i].status_flags);
#endif
/* Convert to big endian for the protocol. */
diff --git a/server/sockets.c b/server/sockets.c
index 1585a09..119cb99 100644
--- a/server/sockets.c
+++ b/server/sockets.c
@@ -365,7 +365,7 @@ accept_connection (int listen_sock)
const int flag = 1;
thread_data = malloc (sizeof *thread_data);
- if (!thread_data) {
+ if (unlikely (!thread_data)) {
perror ("malloc");
return;
}
@@ -409,7 +409,7 @@ accept_connection (int listen_sock)
pthread_attr_setdetachstate (&attrs, PTHREAD_CREATE_DETACHED);
err = pthread_create (&thread, &attrs, start_thread, thread_data);
pthread_attr_destroy (&attrs);
- if (err != 0) {
+ if (unlikely (err != 0)) {
fprintf (stderr, "%s: pthread_create: %s\n", program_name, strerror (err));
close (thread_data->sock);
free (thread_data);
--
2.23.0
5 years, 1 month