[PATCH] Allow configuring the disk image size of a virtual machine

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Christopher Baines
Owner
unassigned
Submitted by
Christopher Baines
Severity
normal

Debbugs page

Christopher Baines wrote 7 years ago
(address . guix-patches@gnu.org)
20170928205416.647d53d7@cbaines.net
Allow configuring the size of the virtual machine disk when using the
virtual-matchine record type.

Christopher Baines (2):
vm: Add a minimum root size.
vm: Add disk-image-size to <virtual-machine>.

gnu/system/vm.scm | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlnNU2hfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XelCA/9EY3fEqnh5xkJPZf6iTrhvDXZR+oypfDz5x7YBnhlyIu2aoYujgmPsXzL
F/EYB2TkJP4WO6MoxvIPH/arKoVlgt57f3QdnOQZdXCMj1octfIMRX5zVbuSLwtf
SDJzdeLAYU+qs/6h/HkZpmC5hFfz2vHvyFNPOdKubKZn4rLsjgLFFnrDmTrVGBAd
iYPgDcdBC14pQcRUAowTEyIZv2RVaOSDS/JTSwy/LmAuXMclPJo0Z7Wl6qULP/WE
0Ruju4spyqNmyjbp1mapCNWUuCXVBCFeyLjZ0fPeTKMoieezshLQLQ8b7w1WZTX3
PVH32U2q0baLQbQXm1j2druYHr6dG6UkIUaEcc8d24yeqnVV6dmzbmMknojbnzpk
D+4yRJ1ouWeuDN8021UE7p0znPeHV92EzHgGSTH5jwHgqSFiXssy8307sHl9f+EV
d7maWTWb5DV3w5TKWOBD0/v6jQSv8HIu4NGOro8KBESJ2qzzKfYKANMRsni32WLE
DwbhyuAnIv6k2SauJQzirVFOkqfIa8zkCwH17S/pTXHPoyHI29jGy5NP6Gra2102
PcePEjqKXE+kN7rC2/7HsZV3AJtueK0JYCEZw4UbPvmdW35pUsEW8ADmVKZWzmxi
TQ6XBht4AFlGkce2IuU4FJIag/vFFIgdfF0wv4YaI25V5x//1Mw=
=99Gj
-----END PGP SIGNATURE-----


Christopher Baines wrote 7 years ago
[PATCH 1/2] vm: Add a minimum root size.
(address . 28635@debbugs.gnu.org)
20170928195754.28688-1-mail@cbaines.net
* gnu/system/vm.scm (qemu-image): When guessing the root-size, use a lower
bound of 20 MiB, otherwise the root file system size is sometimes 0 MiB in
size.
---
gnu/system/vm.scm | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

Toggle diff (22 lines)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index 78143e4f7..d340a8563 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -304,9 +304,12 @@ the image."
#:register-closures? #$register-closures?
#:system-directory #$os-drv))
(root-size #$(if (eq? 'guess disk-image-size)
- #~(estimated-partition-size
- (map (cut string-append "/xchg/" <>)
- graphs))
+ #~(max
+ ;; Minimum 20 MiB root size
+ (* 20 (expt 2 20))
+ (estimated-partition-size
+ (map (cut string-append "/xchg/" <>)
+ graphs)))
(- disk-image-size
(* 50 (expt 2 20)))))
(partitions (list (partition
--
2.14.1
Christopher Baines wrote 7 years ago
[PATCH 2/2] vm: Add disk-image-size to <virtual-machine>.
(address . 28635@debbugs.gnu.org)
20170928195754.28688-2-mail@cbaines.net
* gnu/system/vm.scm (<virtual-machine>): Add disk-image-size.
(port-forwardings->qemu-options): Use disk-image-size from
<virtual-machine>.
---
gnu/system/vm.scm | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)

Toggle diff (43 lines)
diff --git a/gnu/system/vm.scm b/gnu/system/vm.scm
index d340a8563..2f31a615b 100644
--- a/gnu/system/vm.scm
+++ b/gnu/system/vm.scm
@@ -709,6 +709,8 @@ it is mostly useful when FULL-BOOT? is true."
(default #f))
(memory-size virtual-machine-memory-size ;integer (MiB)
(default 256))
+ (disk-image-size virtual-machine-disk-image-size ;integer (bytes)
+ (default 'guess))
(port-forwardings virtual-machine-port-forwardings ;list of integer pairs
(default '())))
@@ -737,12 +739,15 @@ FORWARDINGS is a list of host-port/guest-port pairs."
system target)
;; XXX: SYSTEM and TARGET are ignored.
(match vm
- (($ <virtual-machine> os qemu graphic? memory-size ())
+ (($ <virtual-machine> os qemu graphic? disk-image-size memory-size ())
(system-qemu-image/shared-store-script os
#:qemu qemu
#:graphic? graphic?
- #:memory-size memory-size))
- (($ <virtual-machine> os qemu graphic? memory-size forwardings)
+ #:memory-size memory-size
+ #:disk-image-size
+ disk-image-size))
+ (($ <virtual-machine> os qemu graphic? memory-size disk-image-size
+ forwardings)
(let ((options
`("-net" ,(string-append
"user,"
@@ -751,6 +756,8 @@ FORWARDINGS is a list of host-port/guest-port pairs."
#:qemu qemu
#:graphic? graphic?
#:memory-size memory-size
+ #:disk-image-size
+ disk-image-size
#:options options)))))
;;; vm.scm ends here
--
2.14.1
Christopher Baines wrote 7 years ago
Re: [bug#28198] [PATCH 1/4] vm: Add disk-image-size to <virtual-machine>.
(name . Ludovic Courtès)(address . ludo@gnu.org)
20170929074821.06100e60@cbaines.net
On Tue, 26 Sep 2017 09:14:28 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (76 lines)
> Hi Chris!
>
> Christopher Baines <mail@cbaines.net> skribis:
>
> > On Thu, 31 Aug 2017 14:29:56 +0200
> > ludo@gnu.org (Ludovic Courtès) wrote:
> >
> >> Hi Chris,
> >
> > Thanks for reviewing these patches Ludo, unfortunately its taken me
> > nearly a month to get around to replying.
> >
> > Thankfully, I've made some progress in that time.
> >
> >> Christopher Baines <mail@cbaines.net> skribis:
> >>
> >> > * gnu/system/vm.scm (<virtual-machine>): Add
> >> > disk-image-size.
> >> > (port-forwardings->qemu-options): Use disk-image-size from
> >> > <virtual-machine>.
> >>
> >> In which case is it useful? Perhaps if you want to create lots of
> >> data on the root file system in the MongoDB test?
> >>
> >> Currently <virtual-machine> builds a shared-store VM (like ‘guix
> >> system vm’) in which the root file system has a fixed size that’s
> >> usually good enough.
> >
> > The best answer I have at the moment is that I think MongoDB
> > creates a rather large file, even if it has no data to store in it.
> > I'll do some more investigation to confirm this though.
>
> OK, that’s a good reason anyway. :-)
>
> >> > --- a/gnu/system/vm.scm
> >> > +++ b/gnu/system/vm.scm
> >> > @@ -653,6 +653,8 @@ it is mostly useful when FULL-BOOT? is
> >> > true." (default #f))
> >> > (memory-size virtual-machine-memory-size ;integer (MiB)
> >> > (default 256))
> >> > + (disk-image-size virtual-machine-disk-image-size ;integer
> >> > (bytes)
> >> > + (default (* 70 (expt 2 20))))
> >>
> >> I think we can use 'guess here as the default value (and we should
> >> do the same in places where #:disk-image-size has an arbitrary
> >> default.)
> >
> > I've been looking at this in the last few days. Making 'guess the
> > default value here does mean something, and I think it's a good
> > idea.
> >
> > As far as I can tell, for this specific test, these are the 3
> > functions that are called on the way to using the actual size, and
> > the defaults they have:
> >
> > system-qemu-image/shared-store-script default:
> > (* (if full-boot? 500 70)
> > (expt 2 20)))
> >
> > system-qemu-image/shared-store default:
> > (* (if full-boot? 500 30)
> > (expt 2 20)))
> >
> > qemu-image default:
> > 'guess
> >
> > From my tests, if the default in the <virtual-machine> is set to
> > 'guess, then for the mongodb test the guess seems to be 0 MiB at the
> > moment, which doesn't work. I've started looking at setting a
> > sensible default in qemu-image, so that the root filesystem size
> > isn't 0 MiB.
>
> Indeed. Maybe we can go with your patch as-is and investigate the
> problem with 'guess separately. Thoughts?

That's fine with me. I've also now created a separate bug with this
patch, and another to add a default value [1].

I tested it with the memcached system test, and the disk image size was
the same plus the test still passed. I haven't checked the other tests
yet.

-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlnN7LVfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9Xd47g//RZ3W1CeY1S72/5ZVwSi1panfjnE8f3ZxPfnWWi5Xsu9BA8NW2fWvsoxG
A7bpzIyK09aqOhinKgAZDsS7TdNXGQOvyfs7zmF00OKppAh+ntixyqdaa8uMitS0
aV2JSFAbg6/b+wTqMPrfH+RWPsuW4e+ADx+VGSRCCbeUyBLluN+gL+D/rI3cAUSr
yfwypHDS1YF0wmX48Kcmk2SpV2JB6CLyTlLrm/hrwMlXdKPDAhTqce89zmBlF1uI
RWegm5s7n9Ii+sp++BDUhUShetadoK89oSYmt1l+08FkXdAU8kMntqJwDTzLJznS
+X/Q+16bm1fInt88BpxonzBI1nrdl90UUsLRWDfo/N+AMNWfTkR/P3X5R2Q1NYPG
Vi9/loTvymuck+HnhyfDLoLu1f4NPVzW8iuVNNjQBgrFkQDhOaQhm2wNjJDJ+ZY+
doGekWiQu+FUF63vLohboWVSriVJsIoyUhYFoK2US7W3BemvExfZHSiSv7lpVPu7
M5tHKTA8JNqC+ISgFT4ue6HySKSW7MmrR7HuTwYiK7xx0c+RcsZUwUauqYoWZBl2
u0sJ+TyYF6RuqlMaVzPKd8CesvnTa7vW1J+MUY37syAnbHfodEf/6xQsfPYAfdHb
RnyJKbbet+l5VdC84KHLufkwTwn5z6Es3R4h8RzT02ImbQy2DRM=
=+o3L
-----END PGP SIGNATURE-----


Ludovic Courtès wrote 7 years ago
Re: [bug#28635] [PATCH 1/2] vm: Add a minimum root size.
(name . Christopher Baines)(address . mail@cbaines.net)(address . 28635@debbugs.gnu.org)
874lrg8jgr.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (4 lines)
> * gnu/system/vm.scm (qemu-image): When guessing the root-size, use a lower
> bound of 20 MiB, otherwise the root file system size is sometimes 0 MiB in
> size.

LGTM, thanks!

Ludo’.
Ludovic Courtès wrote 7 years ago
Re: [bug#28635] [PATCH 2/2] vm: Add disk-image-size to <virtual-machine>.
(name . Christopher Baines)(address . mail@cbaines.net)(address . 28635@debbugs.gnu.org)
87zi9874uz.fsf@gnu.org
Christopher Baines <mail@cbaines.net> skribis:

Toggle quote (4 lines)
> * gnu/system/vm.scm (<virtual-machine>): Add disk-image-size.
> (port-forwardings->qemu-options): Use disk-image-size from
> <virtual-machine>.

As long as “make check-system TESTS=basic” passes, fine with me!

Thanks,
Ludo’.
Christopher Baines wrote 7 years ago
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 28635-done@debbugs.gnu.org)
20171004072536.0d736c3a@cbaines.net
On Tue, 03 Oct 2017 15:12:04 +0200
ludo@gnu.org (Ludovic Courtès) wrote:

Toggle quote (8 lines)
> Christopher Baines <mail@cbaines.net> skribis:
>
> > * gnu/system/vm.scm (<virtual-machine>): Add disk-image-size.
> > (port-forwardings->qemu-options): Use disk-image-size from
> > <virtual-machine>.
>
> As long as “make check-system TESTS=basic” passes, fine with me!

It failed at first, as I had a the memory-size and disk-image-size
fields the wrong way around in a match statement, but after I fixed
that it worked fine.

I've now pushed these changes, thanks for your review :)
-----BEGIN PGP SIGNATURE-----

iQKTBAEBCgB9FiEEPonu50WOcg2XVOCyXiijOwuE9XcFAlnUfuBfFIAAAAAALgAo
aXNzdWVyLWZwckBub3RhdGlvbnMub3BlbnBncC5maWZ0aGhvcnNlbWFuLm5ldDNF
ODlFRUU3NDU4RTcyMEQ5NzU0RTBCMjVFMjhBMzNCMEI4NEY1NzcACgkQXiijOwuE
9XeKvA//a8S28VYvYuWfrIr6jK2k76kuCGvZa9mjfm6ra+NnrHAPDXlwzhxukmIN
7FGywB/SKYY3fDnO/uW6yMzGr34amkkQ5ADgBbpuiKJyN176ZGK9F2oRMI5b5HUQ
NSOznJiezfwGlnJpMyrZrcJzzfwFC72+xzDHqj4OstXTgWyddFs8Ulq2cppyn7H3
D5Bna9ZCxLRIZOQtrVob0Q93pIBm+eQmYkV4UV+UCrjC5/lyb6nvJ0M9+xjHyWW8
bHHWvcpIUZY4IhSguCu3BQwOqjpItqQU01XqRIwEBHkLqT3QO6zCEaMJ2MqtgGF8
0EekIHq4Bn426+mUJO8WxLf68FsdisntsoQAMligSd4qIkpfZpCC8eHS+8LEzddZ
cqDoXdc4ZoSXwUiTnRZ/7715/qZv7yjUgX6L4nboksML43QVXYjMJo3jnHNE+H2y
luABbNlWl1BzT1MFUxzoe+J8G3D3XbzMqrhbvne3nilorLHPYFqn8v4vSZFHIAJP
i+wVrlpk5aZv/yPjcYbPdmauWPruQ+xzEdQnKvwQY3nrs/on0BMg3pV04yNyrJWI
5KiMxnRmdxP+BMRWlEPSpHQSLossPqbYPfmtrQuvx5qO5sgbBLd5RC1S/jcyOKzF
9/vYbTAhhP3PVOapl2LxwS17SjRwNqhJNg1cjZFs4qtdAyW31uA=
=g10p
-----END PGP SIGNATURE-----


Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 28635@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 28635
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch
You may also tag this issue. See list of standard tags. For example, to set the confirmed and easy tags
mumi command -t +confirmed -t +easy
Or, remove the moreinfo tag and set the help tag
mumi command -t -moreinfo -t +help