[PATCH] daemon: selinux: Add setfiles -vv flags when verbose.
by Richard W.M. Jones
This shows which files are being relabelled. Also only use -q
(suppress non-error output) when we are not verbose.
---
daemon/selinux-relabel.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/daemon/selinux-relabel.c b/daemon/selinux-relabel.c
index 2f48ee6..e7da42d 100644
--- a/daemon/selinux-relabel.c
+++ b/daemon/selinux-relabel.c
@@ -112,8 +112,11 @@ do_selinux_relabel (const char *specfile, const char *path,
ADD_ARG (argv, i, sysroot);
}
- /* Suppress non-error output. */
- ADD_ARG (argv, i, "-q");
+ if (verbose)
+ ADD_ARG (argv, i, "-vv");
+ else
+ /* Suppress non-error output. */
+ ADD_ARG (argv, i, "-q");
/* Add parameters. */
ADD_ARG (argv, i, s_specfile);
--
2.10.2
7 years, 7 months
[PATCH] daemon: selinux: Add setfiles -m option to suppress extra excludes (RHBZ#1433577).
by Richard W.M. Jones
---
daemon/selinux-relabel.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/daemon/selinux-relabel.c b/daemon/selinux-relabel.c
index 112bee1..2f48ee6 100644
--- a/daemon/selinux-relabel.c
+++ b/daemon/selinux-relabel.c
@@ -27,6 +27,8 @@
#include "actions.h"
#include "optgroups.h"
+#include "ignore-value.h"
+
GUESTFSD_EXT_CMD(str_setfiles, setfiles);
#define MAX_ARGS 64
@@ -37,6 +39,20 @@ optgroup_selinuxrelabel_available (void)
return prog_exists (str_setfiles);
}
+static int
+setfiles_has_m_option (void)
+{
+ static int flag = -1;
+ CLEANUP_FREE char *err = NULL;
+
+ if (flag == -1) {
+ ignore_value (command (NULL, &err, str_setfiles, "-m", NULL));
+ flag = err && strstr (err, /* "invalid option -- " */ "'m'") == NULL;
+ }
+
+ return flag;
+}
+
/* Takes optional arguments, consult optargs_bitmask. */
int
do_selinux_relabel (const char *specfile, const char *path,
@@ -83,6 +99,13 @@ do_selinux_relabel (const char *specfile, const char *path,
ADD_ARG (argv, i, "-e"); ADD_ARG (argv, i, s_selinux);
ADD_ARG (argv, i, "-e"); ADD_ARG (argv, i, s_sys);
+ /* You have to use the -m option (where available) otherwise
+ * setfiles puts all the mountpoints on the excludes list for no
+ * useful reason (RHBZ#1433577).
+ */
+ if (setfiles_has_m_option ())
+ ADD_ARG (argv, i, "-m");
+
/* Relabelling in a chroot. */
if (STRNEQ (sysroot, "/")) {
ADD_ARG (argv, i, "-r");
--
2.10.2
7 years, 7 months
Guestmount seems not to sync changes
by 张强
Hi all,
It seems guestmount always fails to flush changes to the mounted qcow2 snapshot.
To reproduce this problem:
1. take an external snapshot for a qcow2
2. guestmount the snapshot
3. do some changes, for example: `echo 123 > /test; cat /test`, right now /test can be seen created and containing the right content
4. fusermount -u {mount-point}
5. virt-cat changed file, for the example above, sometimes /test doesn't exist, sometimes /test does exist but has no content
My libguestfs version is 1.20.11, and it's running on CentOS 6.6.
I tried several ways to work this around, but none of them worked.
I suspect it's a cache problem, so I tried to wait a while before umounting the image, sometimes this way works, sometimes it doesn't.
I also looked into the documentation for syncing and caching options, I tried to mount the image with fuse options like:
guestmount -o direct_io -o sync -o sync_read -o big_writes -w
no luck either.
What could be the cause? Is mounting a snapshot a problem?
Thanks.
7 years, 7 months
[PATCH] v2v: inspect source: Don't tell people twice to run virt-v2v -v -x (RHBZ#1167623).
by Richard W.M. Jones
There were two related bugs in the virt-v2v error messages when source
inspection failed.
Firstly it would print the message about running 'virt-v2v -v -x' twice:
virt-v2v: error: inspection could not detect the source guest (or physical
machine).
Assuming that you are running virt-v2v/virt-p2v on a source which is
supported (and not, for example, a blank disk), then this should not
happen. You should run 'virt-v2v -v -x ... >& log' and attach the complete
log to a new bug report (see http://libguestfs.org).
No root device found in this operating system image.
If reporting bugs, run virt-v2v with debugging enabled and include the
complete output:
virt-v2v -v -x [...]
And secondly it would tell you to run virt-v2v -v -x even if you were
running with verbose messages.
Further fix for https://bugzilla.redhat.com/show_bug.cgi?id=1167623
which updates commit ab7197476de1cb3c8727caf4da429f6293ca4227.
Thanks: Kun Wei.
---
v2v/inspect_source.ml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/v2v/inspect_source.ml b/v2v/inspect_source.ml
index 2b422e003..6f02fb20e 100644
--- a/v2v/inspect_source.ml
+++ b/v2v/inspect_source.ml
@@ -108,7 +108,7 @@ let rec inspect_source root_choice g =
and choose_root root_choice g = function
| [] ->
- error (f_"inspection could not detect the source guest (or physical machine).\n\nAssuming that you are running virt-v2v/virt-p2v on a source which is supported (and not, for example, a blank disk), then this should not happen. You should run 'virt-v2v -v -x ... >& log' and attach the complete log to a new bug report (see http://libguestfs.org).\n\nNo root device found in this operating system image.");
+ error (f_"inspection could not detect the source guest (or physical machine).\n\nAssuming that you are running virt-v2v/virt-p2v on a source which is supported (and not, for example, a blank disk), then this should not happen.\n\nNo root device found in this operating system image.");
| [root] -> root (* only one root, so return it *)
| roots ->
(* If there are multiple roots, use the [--root] option supplied
@@ -212,5 +212,5 @@ and sanity_check_inspection inspect =
and error_if_unknown fieldname value =
if value = "unknown" then
- error (f_"inspection could not detect the source guest (or physical machine).\n\nAssuming that you are running virt-v2v/virt-p2v on a source which is supported (and not, for example, a blank disk), then this should not happen. You should run 'virt-v2v -v -x ... >& log' and attach the complete log to a new bug report (see http://libguestfs.org).\n\nInspection field '%s' was 'unknown'.")
+ error (f_"inspection could not detect the source guest (or physical machine).\n\nAssuming that you are running virt-v2v/virt-p2v on a source which is supported (and not, for example, a blank disk), then this should not happen.\n\nInspection field '%s' was 'unknown'.")
fieldname
--
2.12.0
7 years, 7 months
[PATCH] inspect: get a better icon for ALT Linux guests (RHBZ#1433937)
by Pino Toscano
Use a 64px icon which is in the menu-icons-default package, hopefully
part of the default installation of any flavour.
Updates commit 9928296c1ca8df5bd8f108ed00039adc6468cac3.
Thanks to: Xiang Hua Chen.
---
lib/inspect-icon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/inspect-icon.c b/lib/inspect-icon.c
index 84d4e4a..695f038 100644
--- a/lib/inspect-icon.c
+++ b/lib/inspect-icon.c
@@ -455,7 +455,7 @@ icon_voidlinux (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
return get_png (g, fs, VOIDLINUX_ICON, size_r, 20480);
}
-#define ALTLINUX_ICON "/usr/share/doc/alt-docs/altlogo.png"
+#define ALTLINUX_ICON "/usr/share/icons/hicolor/64x64/apps/altlinux.png"
static char *
icon_altlinux (guestfs_h *g, struct inspect_fs *fs, size_t *size_r)
--
2.9.3
7 years, 7 months
[PATCH 0/4] p2v: fix virt-p2v-make-disk on Debian
by Pino Toscano
Hi,
this small series fixes the generation of Debian-based images using
virt-p2v-make-disk. With this series, the image can boot fine, X is
started, and the p2v interface appears. I haven't tried an actual
conversion, but I don't think there are Debian-specific problems
preventing that.
Thanks,
Pino Toscano (4):
p2v: fix Gtk dependencies on Debian
p2v: remove network-manager-applet Debian dependency
p2v: virt-p2v-make-disk: fix systemd paths
p2v: virt-p2v-make-disk: prevent daemons to run on Debian
p2v/dependencies.m4 | 3 +--
p2v/virt-p2v-make-disk.in | 21 ++++++++++++++++++---
2 files changed, 19 insertions(+), 5 deletions(-)
--
2.9.3
7 years, 7 months
[PATCH] btrfs_filesystem_show: work with another old btrfs version
by Pino Toscano
An old version of btrfs-progs (3.17 in this case) has a different
version string, so adapt our filtering to include this line as well.
Related to/updates commit 839ae5bcd537b3dc4f13bbea6fe40091ebc2b7f0.
---
daemon/btrfs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index d18f518..23513a9 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -2268,7 +2268,8 @@ do_btrfs_filesystem_show (const char *device)
} else if (STRPREFIX (lines[i], "\t*** Some devices missing")) {
reply_with_error_errno (ENODEV, "%s: missing devices", device);
return NULL;
- } else if (STRPREFIX (lines[i], "btrfs-progs v")) {
+ } else if (STRPREFIX (lines[i], "btrfs-progs v") ||
+ STRPREFIX (lines[i], "Btrfs v")) {
/* Older versions of btrfs-progs output also the version string
* (the same as `btrfs --version`. This has been fixed upstream
* since v4.3.1, commit e29ec82e4e66042ca55bf8cd9ef609e3b21a7eb7.
--
2.9.3
7 years, 7 months
[PATCH] python: check return value of Python APIs
by Matteo Cafasso
Addressing issue #1406906.
When constructing the returned objects, check the return value of
Python APIs.
This is especially relevant when dealing with non UTF-8 strings.
A RuntimeError will be raised on failure pointing to the problematic
entry and the field name.
Signed-off-by: Matteo Cafasso <noxdafox(a)gmail.com>
---
generator/python.ml | 143 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 97 insertions(+), 46 deletions(-)
diff --git a/generator/python.ml b/generator/python.ml
index 11dc48102..d03275276 100644
--- a/generator/python.ml
+++ b/generator/python.ml
@@ -152,12 +152,20 @@ and generate_python_structs () =
pr "PyObject *\n";
pr "guestfs_int_py_put_%s_list (struct guestfs_%s_list *%ss)\n" typ typ typ;
pr "{\n";
- pr " PyObject *list;\n";
+ pr " PyObject *list, *element;\n";
pr " size_t i;\n";
pr "\n";
pr " list = PyList_New (%ss->len);\n" typ;
- pr " for (i = 0; i < %ss->len; ++i)\n" typ;
- pr " PyList_SetItem (list, i, guestfs_int_py_put_%s (&%ss->val[i]));\n" typ typ;
+ pr " if (list == NULL)\n";
+ pr " PyErr_SetString (PyExc_RuntimeError, \"PyList_New\");\n";
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " for (i = 0; i < %ss->len; ++i) {\n" typ;
+ pr " element = guestfs_int_py_put_%s (&%ss->val[i]);\n" typ typ;
+ pr " if (element == NULL)\n";
+ pr " return NULL;\n";
+ pr " PyList_SetItem (list, i, element);\n";
+ pr " }\n";
pr " return list;\n";
pr "};\n";
pr "#endif\n";
@@ -171,73 +179,112 @@ and generate_python_structs () =
pr "PyObject *\n";
pr "guestfs_int_py_put_%s (struct guestfs_%s *%s)\n" typ typ typ;
pr "{\n";
- pr " PyObject *dict;\n";
+ pr " PyObject *dict, *value;\n";
pr "\n";
pr " dict = PyDict_New ();\n";
+ pr " if (dict == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError, \"PyDict_New\");\n";
+ pr " return NULL;\n";
+ pr " }\n";
List.iter (
function
| name, FString ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
pr "#ifdef HAVE_PYSTRING_ASSTRING\n";
- pr " PyString_FromString (%s->%s));\n"
- typ name;
+ pr " value = PyString_FromString (%s->%s);\n" typ name;
pr "#else\n";
- pr " PyUnicode_FromString (%s->%s));\n"
- typ name;
- pr "#endif\n"
+ pr " value = PyUnicode_FromString (%s->%s);\n" typ name;
+ pr "#endif\n";
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, FBuffer ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
pr "#ifdef HAVE_PYSTRING_ASSTRING\n";
- pr " PyString_FromStringAndSize (%s->%s, %s->%s_len));\n"
+ pr " value = PyString_FromStringAndSize (%s->%s, %s->%s_len);\n"
typ name typ name;
pr "#else\n";
- pr " PyBytes_FromStringAndSize (%s->%s, %s->%s_len));\n"
+ pr " value = PyBytes_FromStringAndSize (%s->%s, %s->%s_len);\n"
typ name typ name;
- pr "#endif\n"
+ pr "#endif\n";
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, FUUID ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
pr "#ifdef HAVE_PYSTRING_ASSTRING\n";
- pr " PyString_FromStringAndSize (%s->%s, 32));\n"
- typ name;
+ pr " value = PyString_FromStringAndSize (%s->%s, 32);\n" typ name;
pr "#else\n";
- pr " PyBytes_FromStringAndSize (%s->%s, 32));\n"
- typ name;
- pr "#endif\n"
+ pr " value = PyBytes_FromStringAndSize (%s->%s, 32);\n" typ name;
+ pr "#endif\n";
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, (FBytes|FUInt64) ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromUnsignedLongLong (%s->%s));\n"
- typ name
+ pr " value = PyLong_FromUnsignedLongLong (%s->%s);\n" typ name;
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, FInt64 ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromLongLong (%s->%s));\n"
- typ name
+ pr " value = PyLong_FromLongLong (%s->%s);\n" typ name;
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, FUInt32 ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromUnsignedLong (%s->%s));\n"
- typ name
+ pr " value = PyLong_FromUnsignedLong (%s->%s);\n" typ name;
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, FInt32 ->
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyLong_FromLong (%s->%s));\n"
- typ name
+ pr " value = PyLong_FromLong (%s->%s);\n" typ name;
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
| name, FOptPercent ->
- pr " if (%s->%s >= 0)\n" typ name;
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyFloat_FromDouble ((double) %s->%s));\n"
- typ name;
+ pr " if (%s->%s >= 0) {\n" typ name;
+ pr " value = PyFloat_FromDouble ((double) %s->%s);\n" typ name;
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
+ pr " }\n";
pr " else {\n";
pr " Py_INCREF (Py_None);\n";
pr " PyDict_SetItemString (dict, \"%s\", Py_None);\n" name;
pr " }\n"
| name, FChar ->
pr "#ifdef HAVE_PYSTRING_ASSTRING\n";
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyString_FromStringAndSize (&%s->%s, 1));\n"
- typ name;
+ pr " value = PyString_FromStringAndSize (&%s->%s, 1);\n" typ name;
pr "#else\n";
- pr " PyDict_SetItemString (dict, \"%s\",\n" name;
- pr " PyUnicode_FromStringAndSize (&%s->%s, 1));\n"
+ pr " value = PyUnicode_FromStringAndSize (&%s->%s, 1);\n"
typ name;
- pr "#endif\n"
+ pr "#endif\n";
+ pr " if (value == NULL) {\n";
+ pr " PyErr_SetString (PyExc_RuntimeError,\n";
+ pr " \"Error setting %s.%s\");\n" typ name;
+ pr " return NULL;\n";
+ pr " }\n";
+ pr " PyDict_SetItemString (dict, \"%s\", value);\n" name;
) cols;
pr " return dict;\n";
pr "};\n";
@@ -517,16 +564,20 @@ and generate_python_actions actions () =
pr " if (py_r == NULL) goto out;\n";
| RStringList _ ->
pr " py_r = guestfs_int_py_put_string_list (r);\n";
- pr " guestfs_int_free_string_list (r);\n"
+ pr " guestfs_int_free_string_list (r);\n";
+ pr " if (py_r == NULL) goto out;\n";
| RStruct (_, typ) ->
pr " py_r = guestfs_int_py_put_%s (r);\n" typ;
- pr " guestfs_free_%s (r);\n" typ
+ pr " guestfs_free_%s (r);\n" typ;
+ pr " if (py_r == NULL) goto out;\n";
| RStructList (_, typ) ->
pr " py_r = guestfs_int_py_put_%s_list (r);\n" typ;
- pr " guestfs_free_%s_list (r);\n" typ
+ pr " guestfs_free_%s_list (r);\n" typ;
+ pr " if (py_r == NULL) goto out;\n";
| RHashtable n ->
pr " py_r = guestfs_int_py_put_table (r);\n";
- pr " guestfs_int_free_string_list (r);\n"
+ pr " guestfs_int_free_string_list (r);\n";
+ pr " if (py_r == NULL) goto out;\n";
| RBufferOut _ ->
pr "#ifdef HAVE_PYSTRING_ASSTRING\n";
pr " py_r = PyString_FromStringAndSize (r, size);\n";
--
2.11.0
7 years, 7 months
[PATCH v2 0/6] v2v: Pass CPU vendor, model and topology from source to target.
by Richard W.M. Jones
v1 -> v2:
- Support for passing topology through -o glance.
- Support for passing topology through -o rhv.
- Use bool for acpi/apic/pae struct fields in virt-p2v.
- Write the xpath expression in error messages instead of file/line.
- Fix more memory leaks in virt-p2v cpuid.c.
- Passes make check & check-valgrind.
There may be some other minor changes. I believe that everything
mentioned in reviews has been fixed.
7 years, 7 months