[PATCH] ntfsresize: Capture errors sent to stdout (RHBZ#1166618).
by Richard W.M. Jones
ntfsresize sends error messages to stdout. Capture those error
messages.
---
daemon/ntfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/daemon/ntfs.c b/daemon/ntfs.c
index aef45a2..762ca88 100644
--- a/daemon/ntfs.c
+++ b/daemon/ntfs.c
@@ -94,7 +94,7 @@ do_ntfsresize (const char *device, int64_t size, int force)
ADD_ARG (argv, i, device);
ADD_ARG (argv, i, NULL);
- r = commandv (NULL, &err, argv);
+ r = commandvf (NULL, &err, COMMAND_FLAG_FOLD_STDOUT_ON_STDERR, argv);
if (r == -1) {
reply_with_error ("%s: %s", device, err);
return -1;
--
2.1.0
10 years
Re: [Libguestfs] virt-v2v: Died at /usr/bin/virt-p2v-server line 411
by Richard W.M. Jones
On Thu, Nov 20, 2014 at 12:03:43PM +0100, Nicolas Ecarnot wrote:
> Just to be sure : I attached the complete log file into a compressed
> attachement. Did you get it?
Yes, I got the log file.
[...]
> >You could grab it and post it somewhere (but note that registries
> >contain sensitive data such as passwords):
> >
> > mkdir /tmp/registry
> > virt-copy-out -a /path/to/guest.img 'win:C:\windows\system32\config' /tmp/registry
> >
> >(I only need to see the files 'SYSTEM' and 'SOFTWARE')
>
> I don't how to get the guest.img, I guess it would be available at
> some point during the conversion, but I just have a physical server.
>
> And about the two files, is it OK if I provide you the files
> directly coming from the real physical server?
>From the server which is the source of the P2V conversion, yes.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-p2v converts physical machines to virtual machines. Boot with a
live CD or over the network (PXE) and turn machines into KVM guests.
http://libguestfs.org/virt-v2v
10 years
virt-v2v: Died at /usr/bin/virt-p2v-server line 411
by Nicolas Ecarnot
Hi,
In a oVirt 3.4.4 environnement, and using a
virt-p2v-0.9.1-2.20130730.1.el6.centos, I'm trying to convert a windows
2003 server 32 bits into an oVirt KVM image.
I already succeed doing that many times, but now, this is failing :
- All the usual process sounds good :
PXE -> DHCP -> connection to the P2V server -> choosing the profile
-> (checking the debug option) -> running the conversion
But in the end (100%), the only error message I get is :
"virt-v2v: Died at /usr/bin/virt-p2v-server line 411"
which does not help me that much, because it is related to some
conversion made by libguestfs, I suppose, and I correctly installed the
libguestfs-winsupport files into the correct directories.
An evidence of that is a recent failure when converting from KVM to
oVirt (so : _V_2V), SOLVED by installing the correct directories in the
correct places.
As I recently switched in this almost-new virt-p2p version (0.9.1), I
was able to activate some useful logs that are available there :
https://www.ecarnot.net/tmp/virt-p2v-server.1415622286.log.gz
It has been days since I'm trying to contact Matthew via IRC, but he
seems to love travelling away for it, and I pray he would find a minute
to read this and give a hint.
Thank you,
Best regards,
--
Nicolas Ecarnot
10 years
[PATCH] inspection: deb: Seperate epoch field from version
by Nikos Skalkotos
Return it in the app2_epoch field of the guestfs_application2 struct
Signed-off-by: Nikos Skalkotos <skalkoto(a)gmail.com>
---
src/inspect-apps.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/src/inspect-apps.c b/src/inspect-apps.c
index 8e645b7..bd4e6c1 100644
--- a/src/inspect-apps.c
+++ b/src/inspect-apps.c
@@ -439,6 +439,7 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs)
FILE *fp;
char line[1024];
size_t len;
+ int32_t epoch = 0;
CLEANUP_FREE char *name = NULL, *version = NULL, *release = NULL, *arch = NULL;
int installed_flag = 0;
@@ -482,23 +483,31 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs)
else if (STRPREFIX (line, "Version: ")) {
free (version);
free (release);
- char *p = strchr (&line[9], '-');
- if (p) {
- *p = '\0';
- version = safe_strdup (g, &line[9]);
- release = safe_strdup (g, p+1);
+ char *p1, *p2;
+ p1 = strchr (&line[9], ':');
+ if (p1) {
+ *p1++ = '\0';
+ epoch = guestfs___parse_unsigned_int (g, &line[9]); /* -1 on error */
+ } else {
+ p1 = &line[9];
+ epoch = 0;
+ }
+ p2 = strchr (p1, '-');
+ if (p2) {
+ *p2++ = '\0';
+ release = safe_strdup (g, p2);
} else {
- version = safe_strdup (g, &line[9]);
release = NULL;
}
+ version = safe_strdup (g, p1);
}
else if (STRPREFIX (line, "Architecture: ")) {
free (arch);
arch = safe_strdup (g, &line[14]);
}
else if (STREQ (line, "")) {
- if (installed_flag && name && version)
- add_application (g, apps, name, "", 0, version, release ? : "",
+ if (installed_flag && name && version && (epoch >= 0))
+ add_application (g, apps, name, "", epoch, version, release ? : "",
arch ? : "", "", "", "", "");
free (name);
free (version);
--
2.1.3
10 years
How to make virt-builder use qemu:///system instead of qemu:///session
by Niranjan
Greetings
I am trying to create quick fedora20 vm's and using virt-builder for it.
Currently when i run virt-builder on Fedora 21 it fails with below errors:
<snip>
[juno@dhcp207-208 ~]$ virt-builder fedora-20 --cache ~/.cache/virt-builder
[ 1.0] Downloading: http://libguestfs.org/download/builder/fedora-20.xz
[ 1.0] Planning how to build this image
[ 1.0] Uncompressing
[ 9.0] Opening the new disk
libvirt: XML-RPC error : Cannot recv data: Connection reset by peer
virt-builder: error: libguestfs error: could not connect to libvirt (URI =
qemu:///session): Cannot recv data: Connection reset by peer [code=38
domain=7]
If reporting bugs, run virt-builder with debugging enabled and include the
complete output:
virt-builder -v -x [...]
</snip>
Versions used:
libguestfs-tools-c-1.28.2-3.fc21.x86_64
Fedora release 21 (Twenty One)[Host]
libvirt-1.2.9.1-1.fc21.x86_64
I am trying virt-builder as non-root user. This user can connect through libvirt
using qemu:///system.
<snip>
[juno@dhcp207-208 ~]$ virsh -c qemu:///system list
Id Name State
----------------------------------------------------
</snip>
but can't connect using qemu:///session
<snip>
[juno@dhcp207-208 ~]$ virsh -c qemu:///session
error: failed to connect to the hypervisor
error: Cannot recv data: Connection reset by peer
</snip>
Any help in this regard would be helpful.
Regards
Niranjan
10 years
[PATCH] list-applications: Add support for pacman
by Nikos Skalkotos
Extend the guestfs_inspect_list_applications2 API call to work on Arch
Linux guest images.
Signed-off-by: Nikos Skalkotos <skalkoto(a)gmail.com>
---
src/inspect-apps.c | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 137 insertions(+)
diff --git a/src/inspect-apps.c b/src/inspect-apps.c
index 6fb9665..8e645b7 100644
--- a/src/inspect-apps.c
+++ b/src/inspect-apps.c
@@ -60,6 +60,7 @@
static struct guestfs_application2_list *list_applications_rpm (guestfs_h *g, struct inspect_fs *fs);
#endif
static struct guestfs_application2_list *list_applications_deb (guestfs_h *g, struct inspect_fs *fs);
+static struct guestfs_application2_list *list_applications_pacman (guestfs_h *g, struct inspect_fs *fs);
static struct guestfs_application2_list *list_applications_windows (guestfs_h *g, struct inspect_fs *fs);
static void add_application (guestfs_h *g, struct guestfs_application2_list *, const char *name, const char *display_name, int32_t epoch, const char *version, const char *release, const char *arch, const char *install_path, const char *publisher, const char *url, const char *description);
static void sort_applications (struct guestfs_application2_list *);
@@ -145,6 +146,11 @@ guestfs__inspect_list_applications2 (guestfs_h *g, const char *root)
break;
case OS_PACKAGE_FORMAT_PACMAN:
+ ret = list_applications_pacman (g, fs);
+ if (ret == NULL)
+ return NULL;
+ break;
+
case OS_PACKAGE_FORMAT_EBUILD:
case OS_PACKAGE_FORMAT_PISI:
case OS_PACKAGE_FORMAT_PKGSRC:
@@ -520,6 +526,137 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs)
return ret;
}
+static struct guestfs_application2_list *
+list_applications_pacman (guestfs_h *g, struct inspect_fs *fs)
+{
+ CLEANUP_FREE char *desc_file = NULL, *fname = NULL, *line = NULL;
+ CLEANUP_FREE_DIRENT_LIST struct guestfs_dirent_list *local_db = NULL;
+ struct guestfs_application2_list *apps = NULL, *ret = NULL;
+ struct guestfs_dirent *curr = NULL;
+ FILE *fp;
+ size_t i, allocsize = 0;
+ ssize_t len;
+ CLEANUP_FREE char *name = NULL, *version = NULL, *desc = NULL;
+ CLEANUP_FREE char *arch = NULL, *url = NULL;
+ char **key = NULL, *rel = NULL, *ver = NULL, *p;
+ int32_t epoch;
+ const size_t path_len = strlen ("/var/lib/pacman/local/") + strlen ("/desc");
+
+ local_db = guestfs_readdir (g, "/var/lib/pacman/local");
+ if (local_db == NULL)
+ return NULL;
+
+ /* Allocate 'apps' list. */
+ apps = safe_malloc (g, sizeof *apps);
+ apps->len = 0;
+ apps->val = NULL;
+
+ for (i = 0; i < local_db->len; i++) {
+ curr = &local_db->val[i];
+
+ if (curr->ftyp != 'd' || STREQ (curr->name, ".") || STREQ (curr->name, ".."))
+ continue;
+
+ free (fname);
+ fname = safe_malloc (g, strlen (curr->name) + path_len + 1);
+ sprintf (fname, "/var/lib/pacman/local/%s/desc", curr->name);
+ free (desc_file);
+ desc_file = guestfs___download_to_tmp (g, fs, fname, curr->name, 8192);
+
+ /* The desc files are small (4K). If the desc file does not exist or is
+ * larger than the 8K limit we've used, the database is probably corrupted,
+ * but we'll continue with the next package anyway.
+ */
+ if (desc_file == NULL)
+ continue;
+
+ fp = fopen (desc_file, "r");
+ if (fp == NULL) {
+ perrorf (g, "fopen: %s", desc_file);
+ goto out;
+ }
+
+ while ((len = getline(&line, &allocsize, fp)) != -1) {
+ if (len > 0 && line[len-1] == '\n') {
+ line[--len] = '\0';
+ }
+
+ /* empty line */
+ if (len == 0) {
+ key = NULL;
+ continue;
+ }
+
+ if (key != NULL) {
+ *key = safe_strdup (g, line);
+ key = NULL;
+ continue;
+ }
+
+ if (STREQ (line, "%NAME%"))
+ key = &name;
+ else if (STREQ (line, "%VERSION%"))
+ key = &version;
+ else if (STREQ (line, "%DESC%"))
+ key = &desc;
+ else if (STREQ (line, "%URL%"))
+ key = &url;
+ else if (STREQ (line, "%ARCH%"))
+ key = &arch;
+ }
+
+ if ((name == NULL) || (version == NULL) || (arch == NULL))
+ /* Those are mandatory fields. The file is corrupted */
+ goto after_add_application;
+
+ /* version: [epoch:]ver-rel */
+ p = strchr (version, ':');
+ if (p) {
+ *p = '\0';
+ epoch = guestfs___parse_unsigned_int (g, version); /* -1 on error */
+ ver = p + 1;
+ } else {
+ epoch = 0;
+ ver = version;
+ }
+
+ p = strchr (ver, '-');
+ if (p) {
+ *p = '\0';
+ rel = p + 1;
+ } else /* release is a mandatory field */
+ goto after_add_application;
+
+ if ((epoch >= 0) && (ver[0] != '\0') && (rel[0] != '\0'))
+ add_application (g, apps, name, "", epoch, ver, rel, arch, "", "",
+ url ? : "", desc ? : "");
+
+ after_add_application:
+ key = NULL;
+ free (name);
+ free (version);
+ free (desc);
+ free (arch);
+ free (url);
+ name = version = desc = arch = url = NULL;
+ rel = ver = NULL; /* haven't allocated memory for those */
+
+ if (fclose (fp) == -1) {
+ perrorf (g, "fclose: %s", desc_file);
+ goto out;
+ }
+
+ }
+
+ ret = apps;
+
+ out:
+ if (ret == NULL)
+ guestfs_free_application2_list (apps);
+
+ return ret;
+}
+
static void list_applications_windows_from_path (guestfs_h *g, struct guestfs_application2_list *apps, const char **path, size_t path_len);
static struct guestfs_application2_list *
--
2.1.3
10 years
[PATCH] list-applications: Add support for pacman
by Nikos Skalkotos
Extend the guestfs_inspect_list_applications2 API call to work on Arch
Linux guest images.
---
src/inspect-apps.c | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 125 insertions(+)
diff --git a/src/inspect-apps.c b/src/inspect-apps.c
index b62b432..b7a3b0e 100644
--- a/src/inspect-apps.c
+++ b/src/inspect-apps.c
@@ -60,6 +60,7 @@
static struct guestfs_application2_list *list_applications_rpm (guestfs_h *g, struct inspect_fs *fs);
#endif
static struct guestfs_application2_list *list_applications_deb (guestfs_h *g, struct inspect_fs *fs);
+static struct guestfs_application2_list *list_applications_pacman (guestfs_h *g, struct inspect_fs *fs);
static struct guestfs_application2_list *list_applications_windows (guestfs_h *g, struct inspect_fs *fs);
static void add_application (guestfs_h *g, struct guestfs_application2_list *, const char *name, const char *display_name, int32_t epoch, const char *version, const char *release, const char *arch, const char *install_path, const char *publisher, const char *url, const char *description);
static void sort_applications (struct guestfs_application2_list *);
@@ -145,6 +146,11 @@ guestfs__inspect_list_applications2 (guestfs_h *g, const char *root)
break;
case OS_PACKAGE_FORMAT_PACMAN:
+ ret = list_applications_pacman (g, fs);
+ if (ret == NULL)
+ return NULL;
+ break;
+
case OS_PACKAGE_FORMAT_EBUILD:
case OS_PACKAGE_FORMAT_PISI:
case OS_PACKAGE_FORMAT_PKGSRC:
@@ -494,6 +500,125 @@ list_applications_deb (guestfs_h *g, struct inspect_fs *fs)
return ret;
}
+static struct guestfs_application2_list *
+list_applications_pacman (guestfs_h *g, struct inspect_fs *fs)
+{
+ CLEANUP_FREE char *desc_file = NULL, *fname = NULL;
+ struct guestfs_application2_list *apps = NULL, *ret = NULL;
+ struct guestfs_dirent *curr = NULL;
+ FILE *fp;
+ char line[1024];
+ size_t i, len;
+ CLEANUP_FREE char *name = NULL, *version = NULL, *desc = NULL;
+ CLEANUP_FREE char *arch = NULL, *url = NULL;
+ char *release = NULL;
+ char **key = NULL;
+ const size_t path_len = strlen ("/var/lib/pacman/local/") + strlen ("/desc");
+ struct guestfs_dirent_list *local_db = NULL;
+
+ local_db = guestfs_readdir (g, "/var/lib/pacman/local");
+ if (local_db == NULL)
+ return NULL;
+
+ /* Allocate 'apps' list. */
+ apps = safe_malloc (g, sizeof *apps);
+ apps->len = 0;
+ apps->val = NULL;
+
+
+ for (i = 0; i < local_db->len; i++) {
+ curr = &local_db->val[i];
+
+ if (curr->ftyp != 'd' || STREQ (curr->name, ".") || STREQ (curr->name, ".."))
+ continue;
+
+ free (fname);
+ fname = safe_malloc (g, strlen (curr->name) + path_len + 1);
+ sprintf (fname, "/var/lib/pacman/local/%s/desc", curr->name);
+ free (desc_file);
+ desc_file = guestfs___download_to_tmp (g, fs, fname, curr->name, 8192);
+
+ /* The desc files are small (4K). If the desc file does not exist, or is
+ * larger than the 8K limit we've used, the database is probably corrupted,
+ * but we'll continue with the next package anyway.
+ */
+ if (desc_file == NULL)
+ continue;
+
+ fp = fopen (desc_file, "r");
+ if (fp == NULL) {
+ perrorf (g, "fopen: %s", desc_file);
+ goto out;
+ }
+
+ while (fgets (line, sizeof line, fp) != NULL) {
+ len = strlen (line);
+ if (len > 0 && line[len-1] == '\n') {
+ line[--len] = '\0';
+ }
+
+ /* empty line */
+ if (len == 0) {
+ key = NULL;
+ continue;
+ }
+
+ if (key != NULL) {
+ *key = safe_strdup (g, line);
+ key = NULL;
+ continue;
+ }
+
+ if (STREQ(line, "%NAME%"))
+ key = &name;
+ else if (STREQ(line, "%VERSION%"))
+ key = &version;
+ else if (STREQ(line, "%DESC%"))
+ key = &desc;
+ else if (STREQ(line, "%URL%"))
+ key = &url;
+ else if (STREQ(line, "%ARCH%"))
+ key = &arch;
+ }
+
+ if (name) {
+ if (version) {
+ char *p = strchr (version, '-');
+ if (p) {
+ *p = '\0';
+ release = p + 1;
+ }
+ }
+ add_application (g, apps, name, "", 0, version ? : "", release ? : "",
+ arch ? : "", "", "", url ? : "", desc ? : "");
+ }
+
+ free (name);
+ free (version);
+ free (desc);
+ free (arch);
+ free (url);
+ name = version = desc = arch = url = NULL;
+ release = NULL; /* Haven't allocated memory for release */
+
+ if (fclose (fp) == -1) {
+ perrorf (g, "fclose: %s", desc_file);
+ goto out;
+ }
+
+ }
+
+ ret = apps;
+
+ out:
+ guestfs_free_dirent_list (local_db);
+
+ if (ret == NULL)
+ guestfs_free_application2_list (apps);
+
+ return ret;
+}
+
static void list_applications_windows_from_path (guestfs_h *g, struct guestfs_application2_list *apps, const char **path, size_t path_len);
static struct guestfs_application2_list *
--
2.1.3
10 years