Subject: [bug#41961] [PATCH 1/1] services: childhurd: Support more than one instance.

From: Jan Nieuwenhuizen <[email-masked]>
Date: Sun, 21 Jun 2020 11:06:41 +0200

Mathieu Othacehe writes:

Hey Mathieu,

>> * gnu/services/virtualization.scm (<hurd-vm-configuration>)[id,net-options]:
>> New fields.
>> (hurd-vm-net-options): New prodecure.  Parameterize port forwarding with ID.
>                                ^
>                                typo

Oops, thanks.

>> +@item @code{options} (default: @code{'("--snapshot" "--hda")})
>>  The extra options for running QEMU.
>
> Does it really make sense to have "--hda" standalone here, without a
> specific image argument?

Hmm...yes, this looked a bit awkward to me too.  It's being used like
this:

o--8<---------------cut here---------------start------------->8---
  (let ((image       (hurd-vm-configuration-image config))
     ...)
    (define vm-command
      #~(list
         (string-append #$qemu "/bin/qemu-system-i386")
         #$@(if (file-exists? "/dev/kvm") '("--enable-kvm") '())
         "-m" (number->string #$memory-size)
         #$@net-options
         #$@options
         #+image))
--8<---------------cut here---------------end--------------->8---

so that you can play with options and image; have the
"hurd-vm-configuration-image" procedure to return anything, something
that may require something else than --hda <image>...but it's quite
implicit.  Ideas?

>> +  (net-options hurd-vm-configuration-net-options        ;list of string
>> +               (thunked)
>> +               (default (hurd-vm-net-options this-record))))
>
> Why does it need to be thunked?

It uses ID from the configuration like so

--8<---------------cut here---------------start------------->8---
(define (hurd-vm-net-options config)
  (let ((id (or (hurd-vm-configuration-id config) 0)))
    (define (qemu-vm-port base)
      (number->string (+ base (* 1000 id))))
    [...]
     ",hostfwd=tcp:127.0.0.1:" (qemu-vm-port 10022) "-:2222"
    [...]))
--8<---------------cut here---------------end--------------->8---

to fix parameterize the ports for QEMU.  Is there a better way to do
that?

> Otherwise this looks nice!

Great, thanks!

Greetigs,
Janneke

-- 
Jan Nieuwenhuizen <[email-masked]> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com