[PATCH 1/2] lib: write: Remove unused variable.
by Richard W.M. Jones
---
lib/write.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/lib/write.c b/lib/write.c
index 8c4dd8e..384c6b2 100644
--- a/lib/write.c
+++ b/lib/write.c
@@ -954,7 +954,6 @@ hivex_node_set_values (hive_h *h, hive_node_h node,
for (i = 0; i < nr_values; ++i) {
/* Allocate vk record to store this (key, value) pair. */
static const char vk_id[2] = { 'v', 'k' };
- size_t name_len = strlen (values[i].key);
size_t recoded_name_len;
int use_utf16;
char* recoded_name = _hivex_encode_string (values[i].key, &recoded_name_len,
--
1.8.4.2
10 years, 11 months
IRC question: virt-builder & size of qcow2 output files
by Richard W.M. Jones
This question was asked on IRC:
$ virt-builder centos-6 --output box.img --format qcow2 --size 40G # ...
$ qemu-img convert -O qcow2 box.img box-qcow2.img
$ ls -lAhs
1.6G -rw-r--r--. 1 james 41G Jan 2 21:53 box.img
1.1G -rw-r--r--. 1 james 1.1G Jan 3 18:54 box-qcow2.img
$ file box*
box.img: QEMU QCOW Image (v2), 42949672960 bytes
box-qcow2.img: QEMU QCOW Image (v2), 42949672960 bytes
I can reproduce this as well. It turns out to be because virt-builder
runs the following command to create the output container:
qemu-img create -f qcow2 -o preallocation=metadata box.img 42949672960
which you can see produces an apparently huge, but *sparse* file:
$ ls -lh box.img
-rw-r--r--. 1 rjones rjones 41G Jan 4 12:56 box.img
$ du -sh box.img
6.4M box.img
Note that the output file from virt-builder is also sparse:
$ ls -lh box.img
-rw-r--r--. 1 rjones rjones 41G Jan 4 12:55 box.img
$ du -sh box.img
935M box.img
so I don't think this counts as a bug, but I'm surprised that qemu-img
+ -o preallocation=metadata causes such an (apparently) huge file to
be created. It's not taking up as much disk space as it appears to.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
10 years, 11 months
libguestfs build fails with: /usr/lib64/golang/pkg/linux_amd64/libguestfs.org/guestfs.a -- no such file
by Kashyap Chamarthy
I'm on libguestfs Fedora git master branch:
$ git log | head -1
commit 8eb1aa2406632eb4202bbd976459334854295a77
$ yum-builddep libguestfs
$ fedpkg local
Results in:
==========
.
.
.
make[4]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject'
Making all in docs
make[4]: Entering directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject/docs'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject/docs'
make[3]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject'
make[2]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/gobject'
Making all in golang
make[2]: Entering directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/golang'
../run go install libguestfs.org/guestfs
go install libguestfs.org/guestfs: open
/usr/lib64/golang/pkg/linux_amd64/libguestfs.org/guestfs.a: permission denied
make[2]: *** [pkg/linux_amd64/libguestfs.org/guestfs.a] Error 1
make[2]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18/golang'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory
`/home/kashyap/fedora-packaging/libguestfs/master/libguestfs-1.25.18'
make: *** [all] Error 2
error: Bad exit status from /var/tmp/rpm-tmp.wnFopm (%build)
==========
There's no such file as guestfs.a in the above said directory:
==========
$ tree /usr/lib64/golang/pkg/linux_amd64/libguestfs.org/
/usr/lib64/golang/pkg/linux_amd64/libguestfs.org/
└── guestfs
1 directory, 0 files
==========
What am I missing?
Thanks in advance.
--
/kashyap
10 years, 11 months
[PATCH] libvirt-auth: Provide a friendlier wrapper around virConnectAuthPtrDefault (RHBZ#1044014).
by Richard W.M. Jones
---
src/guestfs-internal.h | 1 +
src/libvirt-auth.c | 55 +++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 46 insertions(+), 10 deletions(-)
diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h
index 5356920..d81fa6b 100644
--- a/src/guestfs-internal.h
+++ b/src/guestfs-internal.h
@@ -469,6 +469,7 @@ struct guestfs_h
unsigned int nr_supported_credentials;
int supported_credentials[NR_CREDENTIAL_TYPES];
const char *saved_libvirt_uri; /* Doesn't need to be freed. */
+ bool wrapper_warning_done;
unsigned int nr_requested_credentials;
virConnectCredentialPtr requested_credentials;
#endif
diff --git a/src/libvirt-auth.c b/src/libvirt-auth.c
index fb18f8a..f8ed1b1 100644
--- a/src/libvirt-auth.c
+++ b/src/libvirt-auth.c
@@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <stdbool.h>
#ifdef HAVE_LIBVIRT
#include <libvirt/libvirt.h>
@@ -147,6 +148,34 @@ libvirt_auth_callback (virConnectCredentialPtr cred,
return 0;
}
+/* Libvirt provides a default authentication handler. However it is
+ * confusing to end-users
+ * (https://bugzilla.redhat.com/show_bug.cgi?id=1044014#c0).
+ *
+ * Unfortunately #1 the libvirt handler cannot easily be modified to
+ * make it non-confusing, but unfortunately #2 we have to actually
+ * call it because it handles all the policykit crap.
+ *
+ * Therefore we add a wrapper around it here.
+ */
+static int
+libvirt_auth_default_wrapper (virConnectCredentialPtr cred,
+ unsigned int ncred,
+ void *gv)
+{
+ guestfs_h *g = gv;
+
+ if (!g->wrapper_warning_done) {
+ printf (_("libvirt needs authentication to connect to libvirt URI %s\n"
+ "(see also: http://libvirt.org/auth.html http://libvirt.org/uri.html)\n"),
+ g->saved_libvirt_uri ? g->saved_libvirt_uri : "NULL");
+ g->wrapper_warning_done = true;
+ }
+
+ return virConnectAuthPtrDefault->cb (cred, ncred,
+ virConnectAuthPtrDefault->cbdata);
+}
+
static int
exists_libvirt_auth_event (guestfs_h *g)
{
@@ -165,31 +194,37 @@ guestfs___open_libvirt_connection (guestfs_h *g, const char *uri,
unsigned int flags)
{
virConnectAuth authdata;
- virConnectAuthPtr authdataptr;
virConnectPtr conn;
+ const char *authtype;
+
+ g->saved_libvirt_uri = uri;
+ g->wrapper_warning_done = false;
/* Did the caller register a GUESTFS_EVENT_LIBVIRT_AUTH event and
* call guestfs_set_libvirt_supported_credentials?
*/
if (g->nr_supported_credentials > 0 && exists_libvirt_auth_event (g)) {
+ authtype = "custom";
memset (&authdata, 0, sizeof authdata);
authdata.credtype = g->supported_credentials;
authdata.ncredtype = g->nr_supported_credentials;
authdata.cb = libvirt_auth_callback;
authdata.cbdata = g;
- authdataptr = &authdata;
- g->saved_libvirt_uri = uri;
}
- else
- authdataptr = virConnectAuthPtrDefault;
+ else {
+ /* Wrapper around libvirt's virConnectAuthPtrDefault, see comment
+ * above.
+ */
+ authtype = "default+wrapper";
+ authdata = *virConnectAuthPtrDefault;
+ authdata.cb = libvirt_auth_default_wrapper;
+ authdata.cbdata = g;
+ }
debug (g, "opening libvirt handle: URI = %s, auth = %s, flags = %u",
- uri ? uri : "NULL",
- authdataptr == virConnectAuthPtrDefault
- ? "virConnectAuthPtrDefault" : "<virConnectAuth *>",
- flags);
+ uri ? uri : "NULL", authtype, flags);
- conn = virConnectOpenAuth (uri, authdataptr, flags);
+ conn = virConnectOpenAuth (uri, &authdata, flags);
if (conn)
debug (g, "successfully opened libvirt handle: conn = %p", conn);
--
1.8.4.2
10 years, 11 months
[PATCH] Allow ./configure --without-qemu.
by Richard W.M. Jones
From: "Richard W.M. Jones" <rjones(a)redhat.com>
This means there will be no default hypervisor, and effectively the
user will always have to specify one (eg. by setting LIBGUESTFS_HV or
calling guestfs_set_hv).
This is useful on platforms where qemu doesn't work, or where qemu is
not needed (eg. if you want to use UML, or you just want to compile
libguestfs without using/testing it).
---
configure.ac | 125 ++++++++++++++++++++++-------------------
src/handle.c | 28 ++++++++-
src/launch-direct.c | 4 ++
src/launch-libvirt.c | 4 ++
tests/regressions/rhbz501893.c | 2 +
5 files changed, 105 insertions(+), 58 deletions(-)
diff --git a/configure.ac b/configure.ac
index de0455e..6e93221 100644
--- a/configure.ac
+++ b/configure.ac
@@ -737,80 +737,90 @@ default_qemu="qemu-kvm kvm $qemu_system qemu"
AC_ARG_WITH([qemu],
[AS_HELP_STRING([--with-qemu="bin1 bin2 ..."],
[set default QEMU binary @<:@default="[qemu-kvm] qemu-system-<host> qemu"@:>@])],
- [],
- [with_qemu="$default_qemu"])
-AC_PATH_PROGS([QEMU],[$with_qemu],[no],
- [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/libexec])
-test "x$QEMU" = "xno" && AC_MSG_ERROR([qemu must be installed])
-AC_DEFINE_UNQUOTED([QEMU],["$QEMU"],[Location of qemu binary.])
+ dnl --with-qemu or --without-qemu:
+ [],
+ dnl neither option was given:
+ [with_qemu="$default_qemu"]
+)
-dnl Does the user wish to specify -M, -cpu or other qemu options?
-AC_MSG_CHECKING([if the user specified extra options for qemu command line])
-AC_ARG_WITH([qemu-options],
- [AS_HELP_STRING([--with-qemu-options="-M ... -cpu ... etc"],
- [pass extra options for qemu command line @<:@default=no@:>@])],
- [QEMU_OPTIONS="$withval"],
- [QEMU_OPTIONS=no])
-AS_IF([test "x$QEMU_OPTIONS" = "xno"],[
- AC_MSG_RESULT([no])
- QEMU_OPTIONS=
+AS_IF([test "x$with_qemu" = "xno"],[
+ AC_MSG_WARN([qemu was disabled, libguestfs may not work at all])
+ QEMU=no
],[
- AC_MSG_RESULT([$QEMU_OPTIONS])
-])
-AC_DEFINE_UNQUOTED([QEMU_OPTIONS],["$QEMU_OPTIONS"],
- [Extra options for qemu command line.])
+ AC_PATH_PROGS([QEMU],[$with_qemu],[no],
+ [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin$PATH_SEPARATOR/usr/libexec])
+ test "x$QEMU" = "xno" && AC_MSG_ERROR([qemu must be installed])
-dnl Check that the chosen qemu has virtio-serial support.
-dnl For historical reasons this can be disabled by setting vmchannel_test=no.
-if test "x$vmchannel_test" != "xno"; then
- AC_MSG_CHECKING([that $QEMU -help works])
- if $QEMU -help >&AS_MESSAGE_LOG_FD 2>&1; then
- AC_MSG_RESULT([yes])
- else
+ AC_DEFINE_UNQUOTED([QEMU],["$QEMU"],[Location of qemu binary.])
+
+ dnl Does the user wish to specify -M, -cpu or other qemu options?
+ AC_MSG_CHECKING([if the user specified extra options for qemu command line])
+ AC_ARG_WITH([qemu-options],
+ [AS_HELP_STRING([--with-qemu-options="-M ... -cpu ... etc"],
+ [pass extra options for qemu command line @<:@default=no@:>@])],
+ [QEMU_OPTIONS="$withval"],
+ [QEMU_OPTIONS=no])
+ AS_IF([test "x$QEMU_OPTIONS" = "xno"],[
AC_MSG_RESULT([no])
- AC_MSG_FAILURE(
+ QEMU_OPTIONS=
+ ],[
+ AC_MSG_RESULT([$QEMU_OPTIONS])
+ ])
+ AC_DEFINE_UNQUOTED([QEMU_OPTIONS],["$QEMU_OPTIONS"],
+ [Extra options for qemu command line.])
+
+ dnl Check that the chosen qemu has virtio-serial support.
+ dnl For historical reasons this can be disabled by setting
+ dnl vmchannel_test=no.
+ if test "x$vmchannel_test" != "xno"; then
+ AC_MSG_CHECKING([that $QEMU -help works])
+ if $QEMU -help >&AS_MESSAGE_LOG_FD 2>&1; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE(
[$QEMU -help: command failed.
This could be a very old version of qemu, or qemu might not be
working.
])
- fi
+ fi
- AC_MSG_CHECKING([that $QEMU -version works])
- if $QEMU -version >&AS_MESSAGE_LOG_FD 2>&1; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- AC_MSG_FAILURE(
+ AC_MSG_CHECKING([that $QEMU -version works])
+ if $QEMU -version >&AS_MESSAGE_LOG_FD 2>&1; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE(
[$QEMU -version: command failed.
This could be a very old version of qemu, or qemu might not be
working.
])
- fi
+ fi
- AC_MSG_CHECKING([for $QEMU version >= 1])
- if $QEMU -version | grep -sq 'version @<:@1-@:>@'; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- AC_MSG_FAILURE([$QEMU version must be >= 1.0.])
- fi
+ AC_MSG_CHECKING([for $QEMU version >= 1])
+ if $QEMU -version | grep -sq 'version @<:@1-@:>@'; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([$QEMU version must be >= 1.0.])
+ fi
- AC_MSG_CHECKING([that $QEMU -display none -machine accel=kvm:tcg -device ? works])
- if $QEMU -display none -machine accel=kvm:tcg -device \? >&AS_MESSAGE_LOG_FD 2>&1; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- AC_MSG_FAILURE([$QEMU -display none -machine accel=kvm:tcg -device ? doesn't work.])
- fi
+ AC_MSG_CHECKING([that $QEMU -display none -machine accel=kvm:tcg -device ? works])
+ if $QEMU -display none -machine accel=kvm:tcg -device \? >&AS_MESSAGE_LOG_FD 2>&1; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE([$QEMU -display none -machine accel=kvm:tcg -device ? doesn't work.])
+ fi
- AC_MSG_CHECKING([for virtio-serial support in $QEMU])
- if $QEMU $QEMU_OPTIONS -display none -machine accel=kvm:tcg -device \? 2>&1 | grep -sq virtio-serial; then
- AC_MSG_RESULT([yes])
- else
- AC_MSG_RESULT([no])
- AC_MSG_FAILURE(
+ AC_MSG_CHECKING([for virtio-serial support in $QEMU])
+ if $QEMU $QEMU_OPTIONS -display none -machine accel=kvm:tcg -device \? 2>&1 | grep -sq virtio-serial; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_FAILURE(
[I did not find virtio-serial support in
$QEMU.
@@ -831,8 +841,9 @@ If I am using the wrong qemu or you want to compile qemu from source
and install it in another location, then you should configure with
the --with-qemu option.
])
+ fi
fi
-fi
+])
dnl Enable packet dumps when in verbose mode. This generates lots
dnl of debug info, only useful for people debugging the RPC mechanism.
diff --git a/src/handle.c b/src/handle.c
index fa96d95..af7d956 100644
--- a/src/handle.c
+++ b/src/handle.c
@@ -107,7 +107,15 @@ guestfs_create_flags (unsigned flags, ...)
g->path = strdup (GUESTFS_DEFAULT_PATH);
if (!g->path) goto error;
+#ifdef QEMU
g->hv = strdup (QEMU);
+#else
+ /* configure --without-qemu, so set QEMU to something which will
+ * definitely fail. The user is expected to override the hypervisor
+ * by setting an environment variable or calling set_hv.
+ */
+ g->hv = strdup ("false");
+#endif
if (!g->hv) goto error;
/* Get program name. */
@@ -467,8 +475,26 @@ guestfs__get_path (guestfs_h *g)
int
guestfs__set_qemu (guestfs_h *g, const char *qemu)
{
+ char *new_hv;
+
+ /* Only this deprecated set_qemu API supports using NULL as a
+ * parameter, to mean set it back to the default QEMU. The new
+ * set_hv API does not allow callers to do this.
+ */
+ if (qemu == NULL) {
+#ifdef QEMU
+ new_hv = safe_strdup (g, QEMU);
+#else
+ error (g, _("configured --without-qemu so calling guestfs_set_qemu with qemu == NULL is an error"));
+ return -1;
+#endif
+ }
+ else
+ new_hv = safe_strdup (g, qemu);
+
free (g->hv);
- g->hv = qemu == NULL ? safe_strdup (g, QEMU) : safe_strdup (g, qemu);
+ g->hv = new_hv;
+
return 0;
}
diff --git a/src/launch-direct.c b/src/launch-direct.c
index f45f582..2d4073a 100644
--- a/src/launch-direct.c
+++ b/src/launch-direct.c
@@ -101,6 +101,7 @@ static int qemu_supports_device (guestfs_h *g, struct backend_direct_data *, con
static int qemu_supports_virtio_scsi (guestfs_h *g, struct backend_direct_data *);
static char *qemu_escape_param (guestfs_h *g, const char *param);
+#ifdef QEMU_OPTIONS
/* Like 'add_cmdline' but allowing a shell-quoted string of zero or
* more options. XXX The unquoting is not very clever.
*/
@@ -156,6 +157,7 @@ add_cmdline_shell_unquoted (guestfs_h *g, struct stringsbuf *sb,
options = nextp;
}
}
+#endif /* defined QEMU_OPTIONS */
/* On Debian, /dev/kvm is mode 0660 and group kvm, so users need to
* add themselves to the kvm group otherwise things are going to be
@@ -587,8 +589,10 @@ launch_direct (guestfs_h *g, void *datav, const char *arg)
/* Add the extra options for the qemu command line specified
* at configure time.
*/
+#ifdef QEMU_OPTIONS
if (STRNEQ (QEMU_OPTIONS, ""))
add_cmdline_shell_unquoted (g, &cmdline, QEMU_OPTIONS);
+#endif
/* Add any qemu parameters. */
for (hp = g->hv_params; hp; hp = hp->next) {
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index b5650ea..e3ebd51 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -622,7 +622,11 @@ parse_capabilities (guestfs_h *g, const char *capabilities_xml,
static int
is_custom_hv (guestfs_h *g)
{
+#ifdef QEMU
return g->hv && STRNEQ (g->hv, QEMU);
+#else
+ return 1;
+#endif
}
#if HAVE_LIBSELINUX
diff --git a/tests/regressions/rhbz501893.c b/tests/regressions/rhbz501893.c
index fdd49c8..f4091bf 100644
--- a/tests/regressions/rhbz501893.c
+++ b/tests/regressions/rhbz501893.c
@@ -50,7 +50,9 @@ main (int argc, char *argv[])
assert (guestfs_set_path (g, NULL) == 0);
assert (guestfs_set_append (g, NULL) == 0);
+#ifdef QEMU
assert (guestfs_set_qemu (g, NULL) == 0);
+#endif
guestfs_close (g);
exit (EXIT_SUCCESS);
--
1.8.3.1
10 years, 11 months