[PATCH libldm] Fix crash while creating mapper for a volume which lacks all components.
by Mykola Ivanets
How to reproduce:
1. Extract test images from test/data/ldm-data.tar.xz
2. losetup --show -f test/data/ldm-2003r2-simple-1.img
Let's assume image file was associated with /dev/loop0
3. ldmtool -d /dev/loop0 create all
Result: One LDM volume which contains all required components on the
associated loop device will be mapped but application crashes on further
attempt to do the same for incomplete volumes with error "Error in
`ldmtool': free(): invalid pointer: 0x.......".
Reason: _dm_create_spanned and _dm_create_striped functions define
static local variable "static GString *name" which is at the same time a
function return value. It is passed up to the call stack and is freed
in _ldm_vol_action function. An attempt to free the same pointer will
be made if ldmtool successfully creates some volume first and then will
try to create incomplete volume. Which will cause application crash.
---
src/ldm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/ldm.c b/src/ldm.c
index 19a0663..372b0d7 100644
--- a/src/ldm.c
+++ b/src/ldm.c
@@ -2615,7 +2615,7 @@ _dm_create_part(const LDMPartitionPrivate * const part, uint32_t cookie,
static GString *
_dm_create_spanned(const LDMVolumePrivate * const vol, GError ** const err)
{
- static GString *name = NULL;
+ GString *name = NULL;
guint i = 0;
struct dm_target *targets = g_malloc(sizeof(*targets) * vol->parts->len);
@@ -2682,7 +2682,7 @@ out:
static GString *
_dm_create_striped(const LDMVolumePrivate * const vol, GError ** const err)
{
- static GString *name = NULL;
+ GString *name = NULL;
struct dm_target target;
target.start = 0;
--
2.17.0
6 years, 6 months
[PATCH] v2v: update results of test-v2v-i-ova-snapshots for non-json
by Pino Toscano
When using non-JSON disk notation, the disk will be the snapshot #2.
Fixes commit e5946165c8ea78e0e91c4cfdb5e793526cd638e1.
---
v2v/test-v2v-i-ova-snapshots.expected | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/test-v2v-i-ova-snapshots.expected b/v2v/test-v2v-i-ova-snapshots.expected
index 97bce58ad..a64843b35 100644
--- a/v2v/test-v2v-i-ova-snapshots.expected
+++ b/v2v/test-v2v-i-ova-snapshots.expected
@@ -13,7 +13,7 @@ hypervisor type: vmware
video:
sound:
disks:
- disk1.vmdk (vmdk) [scsi]
+ disk1.vmdk.000000002 (vmdk) [scsi]
removable media:
CD-ROM [ide] in slot 0
NICs:
--
2.14.3
6 years, 6 months
[PATCH libldm v2 0/1] Make libldm to parse and return volume GUID.
by Mykola Ivanets
v2: wrap commit message, "PATCH libldm" prefix.
The result of this patch might be used by libguestfs to return drive
mappings for LDM volumes.
Note, that "show volume" ldmtool command already returns hint which
is a drive letter assigned by Windows to corresponding volume. But
it is not reliable source of information. More over, in multiboot
environment it will be unclear which drive letter belongs to which
operating system. Volume GUID allows to overcome this shortcoming.
Mykola Ivanets (1):
Make libldm to parse and return volume GUID.
src/ldm.c | 6 ++++--
src/ldm.h | 10 ++++++++++
src/ldmtool.c | 3 +++
3 files changed, 17 insertions(+), 2 deletions(-)
--
2.17.0
6 years, 6 months
[PATCH libldm v3 0/2] Make libldm to parse and return volume GUID.
by Mykola Ivanets
v2: wrap commit message, "PATCH libldm" prefix.
v3: correctly initialize and free GLib resources.
The result of this patch might be used by libguestfs to return drive
mappings for LDM volumes.
Note, that "show volume" ldmtool command already returns hint which
is a drive letter assigned by Windows to corresponding volume. But
it is not reliable source of information. More over, in multiboot
environment it will be unclear which drive letter belongs to which
operating system. Volume GUID allows to overcome this shortcoming.
Mykola Ivanets (2):
Make libldm to parse and return volume GUID.
Make git to ignore all test output files.
src/ldm.c | 29 +++++++++++++++++++++++++++--
src/ldm.h | 10 ++++++++++
src/ldmtool.c | 4 ++++
test/.gitignore | 39 ++++++++++++++++++++-------------------
test/ldmread.c | 9 ++++++---
5 files changed, 67 insertions(+), 24 deletions(-)
--
2.17.0
6 years, 6 months
[PATCH 0/1] libldm: Make libldm to parse and return volume GUID.
by Mykola Ivanets
The result of this patch will be used by libguestfs to return drive mappings
for LDM volumes. Note, that "show volume" ldmtool command already returns
hint which is a drive letter assigned by Windows to corresponding volume.
But it is not reliable source of information. More over, in multiboot
environment it is unclear which drive letter belongs to which operating
system. Volume GUID allows to overcome this shortcomming.
Mykola Ivanets (1):
libldm: Make libldm to parse and return volume GUID.
src/ldm.c | 6 ++++--
src/ldm.h | 10 ++++++++++
src/ldmtool.c | 3 +++
3 files changed, 17 insertions(+), 2 deletions(-)
--
2.17.0
6 years, 6 months
[PATCH] Fix building on macOS
by Adam Robinson
Hello,
I have attached a patch that allowed the build to complete successfully on
macOS.
I haven't tried building the daemon under macOS, but I patched two files
there in a similar manner to some of the other files for consistency (just
the include order for rpc headers).
Thanks,
Adam Robinson
Virtualization and Cloud Infrastructure Senior
Information and Technology Services
University of Michigan
6 years, 6 months
[PATCH] daemon: tweak regexp for file type detection (RHBZ#1575640)
by Pino Toscano
Newer versions of file slightly changed the output, removing the comma
between the type, and the architecture string.
Tweak the regular expression so:
- the comma is optional, but if missing then only the architecture
string will follow
- the architecture string has no commas
---
daemon/filearch.ml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/filearch.ml b/daemon/filearch.ml
index b2c30ae87..a892ba851 100644
--- a/daemon/filearch.ml
+++ b/daemon/filearch.ml
@@ -25,7 +25,7 @@ open Unix_utils
open Utils
let re_file_elf =
- PCRE.compile "ELF (\\d+)-bit (MSB|LSB).*(?:executable|shared object|relocatable), (.+?),"
+ PCRE.compile "ELF (\\d+)-bit (MSB|LSB).*(?:executable|shared object|relocatable)(?:,)? ([^,]+?),"
let re_file_elf_ppc64 = PCRE.compile ".*64.*PowerPC"
--
2.14.3
6 years, 6 months
[PATCH] java: support OpenJDK 10+
by Pino Toscano
Starting OpenJDK 10, the 'javah' utility is no more provided [1], and
its functionality is provided by 'javac' itself. Hence, do not error
out on missing 'javah', and store whether it was found; in case it is
not, then:
1) assume 'javac' has the -h parameter to generate the C header, and
make use of it
2) tell the buildsystem that com_redhat_et_libguestfs_GuestFS.h depends
on the JAR, since the the header is generated at the step (1)
[1] https://bugs.java.com/view_bug.do?bug_id=JDK-8182758
---
java/Makefile.am | 11 +++++++++++
m4/guestfs-java.m4 | 5 ++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/java/Makefile.am b/java/Makefile.am
index 376d89d17..81c20f266 100644
--- a/java/Makefile.am
+++ b/java/Makefile.am
@@ -77,6 +77,9 @@ if HAVE_JAVA
JAVAC_FLAGS = $(EXTRA_JAVAC_FLAGS) -encoding utf-8
JAVADOC_FLAGS = -encoding utf-8
+if !HAVE_JAVAH
+JAVAC_FLAGS += -h .
+endif
# Java source.
@@ -125,10 +128,18 @@ libguestfs_jni_la_LDFLAGS = -version-info $(JNI_VERSION_INFO) -shared
BUILT_SOURCES = com_redhat_et_libguestfs_GuestFS.h
+if HAVE_JAVAH
+
com_redhat_et_libguestfs_GuestFS.h: $(java_prefix)/GuestFS.class
rm -f $@
$(JAVAH) -classpath $(srcdir):. com.redhat.et.libguestfs.GuestFS
+else
+
+com_redhat_et_libguestfs_GuestFS.h: libguestfs-${VERSION}.jar
+
+endif
+
# Documentation.
noinst_SCRIPTS = doc-stamp
diff --git a/m4/guestfs-java.m4 b/m4/guestfs-java.m4
index 9d0f948b6..2ab932ac4 100644
--- a/m4/guestfs-java.m4
+++ b/m4/guestfs-java.m4
@@ -73,9 +73,7 @@ if test "x$with_java" != "xno"; then
else
JAVAC="$JAVA/bin/javac"
fi
- if test ! -x "$JAVA/bin/javah"; then
- AC_MSG_ERROR([missing $JAVA/bin/javah binary])
- else
+ if test -x "$JAVA/bin/javah"; then
JAVAH="$JAVA/bin/javah"
fi
if test ! -x "$JAVA/bin/javadoc"; then
@@ -163,6 +161,7 @@ if test "x$with_java" != "xno"; then
AC_SUBST(JAR_INSTALL_DIR)
AC_SUBST(JNI_INSTALL_DIR)
AC_SUBST(JNI_VERSION_INFO)
+ AM_CONDITIONAL([HAVE_JAVAH],[test -n "$JAVAH"])
fi
AM_CONDITIONAL([HAVE_JAVA],[test "x$with_java" != "xno" && test -n "$JAVAC"])
--
2.14.3
6 years, 6 months
[PATCH] appliance: initialize the appliance_files struct
by Pino Toscano
Some compilers do not manage to figure out that the members of it are
set only when search_appliance() in the end returns 1, which is already
checked. Help them a bit by resetting the appliance_files struct on our
own, so they will not report that 'appliance.kernel', and the others are
used as uninitialized.
---
lib/appliance.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/appliance.c b/lib/appliance.c
index 360d4105f..0fa37339e 100644
--- a/lib/appliance.c
+++ b/lib/appliance.c
@@ -118,6 +118,8 @@ guestfs_int_build_appliance (guestfs_h *g,
struct appliance_files appliance;
+ memset (&appliance, 0, sizeof appliance);
+
if (search_appliance (g, &appliance) != 1)
return -1;
--
2.14.3
6 years, 6 months
[PATCH] common/qemuopts: ensure arg lists are never empty
by Pino Toscano
Since it does not make much sense, then forbid this situation outright:
- change qemuopts_end_arg_list() to return an error if the current arg
list has no elements
- when creating the argv array, assert that each arg list is not empty
---
common/qemuopts/qemuopts.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/common/qemuopts/qemuopts.c b/common/qemuopts/qemuopts.c
index b3e69e306..49550bb21 100644
--- a/common/qemuopts/qemuopts.c
+++ b/common/qemuopts/qemuopts.c
@@ -453,7 +453,15 @@ qemuopts_append_arg_list_format (struct qemuopts *qopts,
int
qemuopts_end_arg_list (struct qemuopts *qopts)
{
- /* Nothing to do, the list is already well-formed. */
+ struct qopt *qopt;
+ size_t len;
+
+ qopt = last_option (qopts);
+ assert (qopt->type == QOPT_ARG_LIST);
+ len = count_strings (qopt->values);
+ if (len == 0)
+ return -1;
+
return 0;
}
@@ -816,7 +824,9 @@ qemuopts_to_argv (struct qemuopts *qopts)
case QOPT_ARG_LIST:
/* We only have to do comma-quoting here. */
values = qopts->options[i].values;
- len = count_strings (values) - 1 /* one for each comma */;
+ len = count_strings (values);
+ assert (len > 0);
+ len -= 1 /* one for each comma */;
for (j = 0; values[j] != NULL; ++j) {
for (k = 0; k < strlen (values[j]); ++k) {
if (values[j][k] == ',') len++;
--
2.14.3
6 years, 6 months