[PATCH 0/2] resize: Split out the command line parsing into Cmdline
by Richard W.M. Jones
Some simple refactoring of virt-resize.
I originally had the idea that we could turn virt-resize into a
library (cf. virt-customize) and use it from virt-builder, but I now
don't think that would make any meaningful difference. In particular
we'd still have to open the handle the same number of times.
These two patches are left over from my work on that.
Rich.
8 years, 11 months
Bug: windows server 2012R2 fails to start after virt-resize
by Maxim Perevedentsev
Hello everyone!
After I ran virt-resize (v1.31.28) on my disk with win2012R2
(partition table [GPT]: VFAT (100M), unknown (128M), NTFS (64G))
My VM fails to boot: black screen informing that
Windows failed to start...
Status: 0xc000000e
Info: an unexpected error has occured.
After some investigations, I realized that Windows remembers the GUID of
disk it is installed to.
If I execute
>guestfish -a win2012.hdd -v
...
><fs> debug sh 'sgdisk -p /dev/sda'
guestfsd: main_loop: new request, len 0x54
/bin/sh -c sgdisk -p /dev/sda
Disk /dev/sda: 136314880 sectors, 65.0 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): B3108127-1775-47B7-ABC1-A56D6761C894
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 136314846
Partitions will be aligned on 2048-sector boundaries
Total free space is 2101181 sectors (1.0 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 206847 100.0 MiB EF00 EFI
2 206848 468991 128.0 MiB 0C01 Microsoft
3 468992 134215679 63.8 GiB 0700 Basic
guestfsd: main_loop: proc 76 (debug) took 0.00 seconds
*set the GUID of original disk*
><fs> debug sh 'sgdisk -U ADAA2225-3F89-4F2C-91DF-02F3E0C2ED67 /dev/sda'
guestfsd: main_loop: new request, len 0x7c
/bin/sh -c sgdisk -U ADAA2225-3F89-4F2C-91DF-02F3E0C2ED67 /dev/sda
[ 70.170139] sda: sda1 sda2 sda3
The operation has completed successfully.
guestfsd: main_loop: proc 76 (debug) took 1.02 seconds
The operation has completed successfully.
After that Windows successfully boots from resized image.
I suggest adding get/set disk GUID to API and to virt-resize as well.
Otherwise it is impossible to resize disks with this particular OS (not
only this one, possibly).
And yeah, libguestfs strips partition names, but windows seems to ignore
that.
Waiting for comments.
--
Your sincerely,
Maxim Perevedentsev
8 years, 11 months
Bug: part_set_name does not enquote name
by Maxim Perevedentsev
Windows server 2012 sets partition names with spaces.
><fs> part-get-name /dev/sda 3
libguestfs: trace: part_get_name "/dev/sda" 3
guestfsd: main_loop: new request, len 0x38
parted -s -m /dev/null
Error: The device /dev/null is so small that it cannot possibly store a
file system or partition table. Perhaps you selected the wrong device?
Warning: Error fsyncing/closing /dev/null: Invalid argument
parted -m -- /dev/sda unit b print
parted -m -- /dev/sda unit b print
libguestfs: trace: part_get_name = "Basic data storage"
Basic data storage
><fs> part-set-name /dev/sda 3 'Basic data storage'
libguestfs: trace: part_set_name "/dev/sda" 3 "Basic data storage"
guestfsd: main_loop: proc 416 (part_get_name) took 0.01 seconds
guestfsd: main_loop: new request, len 0x50
udevadm --debug settle
calling: settle
parted -s -- /dev/sda name 3 Basic data storage
Usage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...]
Apply COMMANDs with PARAMETERS to DEVICE. If no COMMAND(s) are given,
run in
interactive mode.
OPTIONs:
-h, --help displays this help message
-l, --list lists partition layout on all block
devices
-m, --machine displays machine parseable output
-s, --script never prompts for user intervention
-v, --version displays the version
-a, --align=[none|cyl|min|opt] alignment for new partitions
COMMANDs:
align-check TYPE N check partition N for
TYPE(min|opt) alignment
help [COMMAND] print general help, or help
on COMMAND
mklabel,mktable LABEL-TYPE create a new disklabel
(partition table)
mkpart PART-TYPE [FS-TYPE] START END make a partition
name NUMBER NAME name partition NUMBER as NAME
print [devices|free|list,all|NUMBER] display the partition table,
available devices, free space, all found partitions, or a particular
partition
quit exit program
rescue START END rescue a lost partition near
START and END
rm NUMBER delete partition NUMBER
select DEVICE choose the device to edit
disk_set FLAG STATE change the FLAG on selected
device
disk_toggle [FLAG] toggle the state of FLAG on
selected device
set NUMBER FLAG STATE change the FLAG on partition
NUMBER
toggle [NUMBER [FLAG]] toggle the state of FLAG on
partition NUMBER
unit UNIT set the default unit to UNIT
version display the version number
and copyright information of GNU Parted
Report bugs to bug-parted(a)gnu.org
udevadm --debug settle
calling: settle
libguestfs: trace: part_set_name = 0
><fs> part-get-name /dev/sda 3
libguestfs: trace: part_get_name "/dev/sda" 3
guestfsd: main_loop: new request, len 0x38
parted -s -m /dev/null
Error: The device /dev/null is so small that it cannot possibly store a
file system or partition table. Perhaps you selected the wrong device?
Warning: Error fsyncing/closing /dev/null: Invalid argument
parted -m -- /dev/sda unit b print
parted -m -- /dev/sda unit b print
libguestfs: trace: part_get_name = "Basic"
Basic
--
С уважением, Максим Переведенцев
Your sincerely, Maxim Perevedentsev
8 years, 11 months
[PATCH] daemon: improve internal commandrvf
by Pino Toscano
- add a flag to request chroot for the process, which is done only as
very last (before chdir) operation before exec'ing the process in the
child: this avoids using CHROOT_IN & CHROOT_OUT around command*
invocations, and reduces the code spent in chroot mode
- add failure checks for dup2 and open done in child, not proceeding to
executing the process if they fail
- open /dev/null without O_CLOEXEC, so it stays available for the
exec'ed process, and thus we don't need to provide an own fd for stdin
Followup of commit fd2f175ee79d29df101d353e2f380db27b19553a, thanks also
to the notes and hints provided by Mateusz Guzik.
---
daemon/command.c | 17 ++---------------
daemon/daemon.h | 1 +
daemon/guestfsd.c | 39 +++++++++++++++++++++++++++++++--------
3 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/daemon/command.c b/daemon/command.c
index 27a4d0c..c4efa5b 100644
--- a/daemon/command.c
+++ b/daemon/command.c
@@ -244,7 +244,7 @@ do_command (char *const *argv)
{
char *out;
CLEANUP_FREE char *err = NULL;
- int r, dev_null_fd, flags;
+ int r, flags;
CLEANUP_BIND_STATE struct bind_state bind_state = { .mounted = false };
CLEANUP_RESOLVER_STATE struct resolver_state resolver_state =
{ .mounted = false };
@@ -261,17 +261,6 @@ do_command (char *const *argv)
return NULL;
}
- /* Provide /dev/null as stdin for the command, since we want
- * to make sure processes have an open stdin, and it is not
- * possible to rely on the guest to provide it (Linux guests
- * get /dev dynamically populated at runtime by udev).
- */
- dev_null_fd = open ("/dev/null", O_RDONLY|O_CLOEXEC);
- if (dev_null_fd == -1) {
- reply_with_perror ("/dev/null");
- return NULL;
- }
-
if (bind_mount (&bind_state) == -1)
return NULL;
if (enable_network) {
@@ -279,11 +268,9 @@ do_command (char *const *argv)
return NULL;
}
- flags = COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN | dev_null_fd;
+ flags = COMMAND_FLAG_DO_CHROOT;
- CHROOT_IN;
r = commandvf (&out, &err, flags, (const char * const *) argv);
- CHROOT_OUT;
free_bind_state (&bind_state);
free_resolver_state (&resolver_state);
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 7fbb2a2..af6f68c 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -128,6 +128,7 @@ extern char **empty_list (void);
#define COMMAND_FLAG_FD_MASK (1024-1)
#define COMMAND_FLAG_FOLD_STDOUT_ON_STDERR 1024
#define COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN 2048
+#define COMMAND_FLAG_DO_CHROOT 4096
extern int commandf (char **stdoutput, char **stderror, int flags,
const char *name, ...) __attribute__((sentinel));
diff --git a/daemon/guestfsd.c b/daemon/guestfsd.c
index 0a29aa6..47245f7 100644
--- a/daemon/guestfsd.c
+++ b/daemon/guestfsd.c
@@ -932,21 +932,44 @@ commandrvf (char **stdoutput, char **stderror, int flags,
signal (SIGPIPE, SIG_DFL);
close (0);
if (flag_copy_stdin) {
- dup2 (flag_copy_fd, STDIN_FILENO);
+ if (dup2 (flag_copy_fd, STDIN_FILENO) == -1) {
+ perror ("dup2/flag_copy_fd");
+ _exit (EXIT_FAILURE);
+ }
} else {
- /* Set stdin to /dev/null (ignore failure) */
- ignore_value (open ("/dev/null", O_RDONLY|O_CLOEXEC));
+ /* Set stdin to /dev/null. */
+ if (open ("/dev/null", O_RDONLY) == -1) {
+ perror ("open(/dev/null)");
+ _exit (EXIT_FAILURE);
+ }
}
close (so_fd[PIPE_READ]);
close (se_fd[PIPE_READ]);
- if (!(flags & COMMAND_FLAG_FOLD_STDOUT_ON_STDERR))
- dup2 (so_fd[PIPE_WRITE], STDOUT_FILENO);
- else
- dup2 (se_fd[PIPE_WRITE], STDOUT_FILENO);
- dup2 (se_fd[PIPE_WRITE], STDERR_FILENO);
+ if (!(flags & COMMAND_FLAG_FOLD_STDOUT_ON_STDERR)) {
+ if (dup2 (so_fd[PIPE_WRITE], STDOUT_FILENO) == -1) {
+ perror ("dup2/so_fd[PIPE_WRITE]");
+ _exit (EXIT_FAILURE);
+ }
+ } else {
+ if (dup2 (se_fd[PIPE_WRITE], STDOUT_FILENO) == -1) {
+ perror ("dup2/se_fd[PIPE_WRITE]");
+ _exit (EXIT_FAILURE);
+ }
+ }
+ if (dup2 (se_fd[PIPE_WRITE], STDERR_FILENO) == -1) {
+ perror ("dup2/se_fd[PIPE_WRITE]");
+ _exit (EXIT_FAILURE);
+ }
close (so_fd[PIPE_WRITE]);
close (se_fd[PIPE_WRITE]);
+ if (flags & COMMAND_FLAG_DO_CHROOT && sysroot_len > 0) {
+ if (chroot (sysroot) == -1) {
+ perror ("chroot in sysroot");
+ _exit (EXIT_FAILURE);
+ }
+ }
+
ignore_value (chdir ("/"));
execvp (argv[0], (void *) argv);
--
2.1.0
8 years, 11 months
Re: [Libguestfs] unknown/unavailable method for expanding the ntfs filesystem
by Richard W.M. Jones
[Please keep replies on the list!]
On Mon, Dec 14, 2015 at 10:46:00AM +0800, Jeffrey wrote:
>
>
> libguestfs-winsupport-7.1-4.el7.x86_64 doesn't work for me either. :(
>
>
> >./run guestfish -a /dev/null run : supported
> acl yes
> augeas yes
> blkdiscard yes
> blkdiscardzeroes yes
> btrfs yes
> extlinux yes
> fstrim yes
> gdisk yes
> grub no
> hivex yes
> inotify yes
> journal yes
> ldm no
> linuxcaps yes
> linuxfsuuid yes
> linuxmodules yes
> linuxxattrs yes
> luks yes
> lvm2 yes
> mdadm yes
> mknod yes
> ntfs3g no
> ntfsprogs no
[...]
> It seems guestfish can not find ntfs3g and ntfsprogs. I have tried
> installing "ntfs-3g" and "ntfsprogs" packages from epel, but
> guestfish still can't find any ntfs support.
This won't work. In RHEL you need to have libguestfs-winsupport.
I didn't realize before you were compiling your own copy of
libguestfs. In that case what you have to do to make it work is:
$ cp /usr/lib64/guestfs/supermin.d/zz-winsupport appliance.d/supermin.d/
since local builds of libguestfs use their own supermin appliance.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html
8 years, 11 months
Plan for libguestfs 1.30
by Richard W.M. Jones
It has been a ludicrously long time (over 8 months) since the last
stable release of libguestfs. So I'd like to plan a new 1.30 release
soon.
Please follow-up if there are features / blockers / bugs that need to
be addressed for 1.30.
As usual, bugs which have "1.30" (without quotes) in the Devel
Whiteboard field in Bugzilla are nominated as blockers for the
release. You can see a list of those here [currently empty]:
https://bugzilla.redhat.com/buglist.cgi?bug_status=NEW&bug_status=ASSIGNE...
For a list of all bugs, go to:
https://bugzilla.redhat.com/buglist.cgi?component=libguestfs&product=Virt...
----------------------------------------------------------------------
It's also worth talking about what I'd like to do *after* 1.30 is out.
This includes:
- threading support
https://www.redhat.com/archives/libguestfs/2015-June/thread.html#00118
- external tests
https://www.redhat.com/archives/libguestfs/2014-October/thread.html#00042
While thread safety is oft talked about, it's external tests which I
consider to be the more important patch series, since it will allow us
to build and test libguestfs more easily and more comprehensively for
Fedora and RHEL. Unfortunately it's the most difficult and invasive
change of the two.
You may have your own ideas, if so follow up here.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top
8 years, 11 months
[PATCH] guestfs.pod: Update reference to libguestfs internals
by Kashyap Chamarthy
---
src/guestfs.pod | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/guestfs.pod b/src/guestfs.pod
index f9dea92c81b5805b9011c99d0aa69e0ce687b834..87355d5c9119656e41a3b89f04f687f8fe7fb1f8 100644
--- a/src/guestfs.pod
+++ b/src/guestfs.pod
@@ -1550,7 +1550,7 @@ such as L<guestfish(1)> with the I<--live> option will "just work".
By calling L</guestfs_set_backend> you can change how the library
connects to the C<guestfsd> daemon in L</guestfs_launch> (read
-L</ARCHITECTURE> for some background).
+L</guestfs-internals> for some background).
The normal backend is C<direct>, where a small appliance is created
containing the daemon, and then the library connects to this.
--
2.4.3
8 years, 11 months
unknown/unavailable method for expanding the ntfs filesystem
by Jeffrey
Hello,everyone
I ran virt-resize(v1.30.4) on my CentOS 7.1 to resize win2008r2 and got the warning message (virt-resize: warning: unknown/unavailable method for expanding the ntfs
filesystem on /dev/sda2):
>/usr/local/libguestfs-1.30.4/run virt-resize --expand /dev/sda2 /images/win2008_src.raw /dev/vg0/win2008_resize_dst
[ 0.0] Examining /images/win2008_src.raw
virt-resize: warning: unknown/unavailable method for expanding the ntfs
filesystem on /dev/sda2
**********
Summary of changes:
/dev/sda1: This partition will be left alone.
/dev/sda2: This partition will be resized from 19.9G to 49.9G.
**********
[ 6.0] Setting up initial partition table on /dev/vg0/win2008_resize_dst
[ 6.2] Copying /dev/sda1
[ 6.5] Copying /dev/sda2
After virt-resize completed its work, obviously the ntfs filesystem on /dev/sda2 has not been resized. I have already installed libguestfs-winsupport-7.2 and I don't know what cause the problem.
Can someone help me in this issue? Thanks!
>rpm -qa|grep libguestfs-winsupport
libguestfs-winsupport-7.2-1.el7.x86_64
>./run virt-resize --machine-readable
virt-resize
ntfsresize-force
32bitok
128-sector-alignment
alignment
align-first
infile-uri
btrfs
xfs
>./run guestfish -a /dev/null run : available
error: incorrect number of arguments
usage: available groups
type 'help available' for more help on available
>./run guestfish -a /dev/null run : filesystem_available ntfs
true
8 years, 11 months
Re: [Libguestfs] Which ISO format/layout does virt-builder expect?
by Richard W.M. Jones
[Please let's keep the replies on the list.]
On Fri, Dec 11, 2015 at 11:58:46AM +0000, Scott Gorton wrote:
> >ISOs are not modifiable by the Linux kernel :-( So none of the tools like guestfish,
> >virt-customize etc etc can work on them.
>
> I wasn't suggesting that virt-builder or any virt-* command attempt
> to manipulate the ISO. Instead, I was wondering if I should create
> the ISO with a different filesystem layout. Mine appears to be an
> installer image that lays out the filesystem upon first install.
> Yours seems to be a fully baked (live-cd) format.
>
> Maybe the way to go would be to configure a VM using virsh and point
> it at my ISO. I'll then run through the boot/installation process
> (to install packages and run our customization scripts), shut the
> system down to produce a qcow2. I can then use your other tools to
> convert the qcow2 into other formats.
In that case I don't understand the problem, but I'll just comment
that virt-customize cannot customize an install CD.
Rich.
--
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
8 years, 11 months