Re: ldom.conf: Support devlias keyword for vdisk
Klemens Nanni schreef op 2020-02-05 21:35: Straight forward diff to allow calling disks names: $ cat ldom.conf domain guest { vcpu 4 memory 8G vnet vdisk "/var/ldom/guest.img" vdisk "/var/ldom/miniroot.fs" devalias=miniroot } $ doas ldomctl start -c guest {ok} devalias ... miniroot /virtual-devices@100/channel-devices@200/disk@1 disk1 /virtual-devices@100/channel-devices@200/disk@1 disk0 /virtual-devices@100/channel-devices@200/disk@0 disk /virtual-devices@100/channel-devices@200/disk@0 ... {ok} boot miniroot Boot device: /virtual-devices@100/channel-devices@200/disk@1 File and args: OpenBSD IEEE 1275 Bootblock 1.4 ... This helps me to navigate inside guests as I no longer have to remember in which order I specified the `vdisk' lines in ldom.conf(5). parse.y code is simply copied from existing vnet code and adapted with s/vnet/vdisk/. It would need the previously sent ldom.conf.5 vnet, although for correctness and consistency only. Feedback? OK? Sounds reasonable. Maybe get some feedback from a parse.y expert as well? Index: config.c === RCS file: /cvs/src/usr.sbin/ldomctl/config.c,v retrieving revision 1.32 diff -u -p -r1.32 config.c --- config.c22 Jan 2020 07:52:38 - 1.32 +++ config.c5 Feb 2020 20:24:12 - @@ -2557,7 +2557,8 @@ guest_add_memory(struct guest *guest, ui } void -guest_add_vdisk(struct guest *guest, uint64_t id, const char *path) +guest_add_vdisk(struct guest *guest, uint64_t id, const char *path, +const char *user_devalias) { struct guest *primary; struct ldc_channel *lc; @@ -2577,6 +2578,8 @@ guest_add_vdisk(struct guest *guest, uin if (id == 0) guest_add_devalias(guest, "disk", devpath); guest_add_devalias(guest, devalias, devpath); + if (user_devalias != NULL) + guest_add_devalias(guest, user_devalias, devpath); free(devalias); free(devpath); } @@ -2849,7 +2852,8 @@ build_config(const char *filename, int n guest_add_memory(guest, -1, domain->memory); i = 0; SIMPLEQ_FOREACH(vdisk, &domain->vdisk_list, entry) - guest_add_vdisk(guest, i++, vdisk->path); + guest_add_vdisk(guest, i++, vdisk->path, + vdisk->devalias); i = 0; SIMPLEQ_FOREACH(vnet, &domain->vnet_list, entry) guest_add_vnetwork(guest, i++, vnet->mac_addr, Index: ldom.conf.5 === RCS file: /cvs/src/usr.sbin/ldomctl/ldom.conf.5,v retrieving revision 1.10 diff -u -p -r1.10 ldom.conf.5 --- ldom.conf.5 13 Jan 2020 09:29:41 - 1.10 +++ ldom.conf.5 5 Feb 2020 20:20:21 - @@ -56,7 +56,7 @@ See .Xr eeprom 8 for a list of OpenPROM variables. This keyword can be used multiple times. -.It Ic vdisk Ar file +.It Ic vdisk Ar file Op Ar keyword Ns = Ns Ar value ... The specified file is used to back a virtual disk of the guest domain. .Ar file @@ -64,6 +64,12 @@ can be a block device node or a disk ima .Cm create-vdisk command. This keyword can be used multiple times. +Valid options are: +.Bl -tag -width Ds +.It Ic devalias Ns = Ns Ar name +Alias the virtual disk as +.Ar name . +.El .It Ic vnet Op Brq Ar keyword Ns = Ns Ar value ... Assign a .Xr vnet 4 Index: ldomctl.h === RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.h,v retrieving revision 1.12 diff -u -p -r1.12 ldomctl.h --- ldomctl.h 4 Jan 2020 15:45:46 - 1.12 +++ ldomctl.h 5 Feb 2020 20:18:43 - @@ -158,6 +158,7 @@ extern uint64_t hv_memsize; struct vdisk { SIMPLEQ_ENTRY(vdisk)entry; const char *path; + const char *devalias; }; struct vnet { Index: parse.y === RCS file: /cvs/src/usr.sbin/ldomctl/parse.y,v retrieving revision 1.15 diff -u -p -r1.15 parse.y --- parse.y 9 Jan 2020 22:06:23 - 1.15 +++ parse.y 5 Feb 2020 20:18:48 - @@ -70,12 +70,17 @@ struct vcpu_opts { uint64_tstride; } vcpu_opts; +struct vdisk_opts { + const char *devalias; +} vdisk_opts; + struct vnet_opts { uint64_tmac_addr; uint64_tmtu; } vnet_opts; void vcput_opts_default(void); +void vdisk_opts_default(void); void vnet_opts_default(void); typedef struct { @@ -83,6 +88,7 @@ typedef struct { int64_t number; char*string; struct vcpu_opts
Re: ldom.conf: Support devlias keyword for vdisk
This looks really useful On Wed, 5 Feb 2020 at 21:38, Klemens Nanni wrote: > On Wed, Feb 05, 2020 at 09:35:25PM +0100, Klemens Nanni wrote: > > Straight forward diff to allow calling disks names: > > > > $ cat ldom.conf > > domain guest { > > vcpu 4 > > memory 8G > > vnet > > vdisk "/var/ldom/guest.img" > > vdisk "/var/ldom/miniroot.fs" devalias=miniroot > > } > The same for network would be trivially to add: > > vnet devalias=netboot > > I have a few domains with two or more vnets, one of them is for > diskless(8) so the following can be as handy; it's little change for > notable convenience: > > {ok} boot netboot > >
Re: ldom.conf: Support devlias keyword for vdisk
On Wed, Feb 05, 2020 at 09:35:25PM +0100, Klemens Nanni wrote: > Straight forward diff to allow calling disks names: > > $ cat ldom.conf > domain guest { > vcpu 4 > memory 8G > vnet > vdisk "/var/ldom/guest.img" > vdisk "/var/ldom/miniroot.fs" devalias=miniroot > } The same for network would be trivially to add: vnet devalias=netboot I have a few domains with two or more vnets, one of them is for diskless(8) so the following can be as handy; it's little change for notable convenience: {ok} boot netboot
ldom.conf: Support devlias keyword for vdisk
Straight forward diff to allow calling disks names: $ cat ldom.conf domain guest { vcpu 4 memory 8G vnet vdisk "/var/ldom/guest.img" vdisk "/var/ldom/miniroot.fs" devalias=miniroot } $ doas ldomctl start -c guest {ok} devalias ... miniroot /virtual-devices@100/channel-devices@200/disk@1 disk1/virtual-devices@100/channel-devices@200/disk@1 disk0/virtual-devices@100/channel-devices@200/disk@0 disk /virtual-devices@100/channel-devices@200/disk@0 ... {ok} boot miniroot Boot device: /virtual-devices@100/channel-devices@200/disk@1 File and args: OpenBSD IEEE 1275 Bootblock 1.4 ... This helps me to navigate inside guests as I no longer have to remember in which order I specified the `vdisk' lines in ldom.conf(5). parse.y code is simply copied from existing vnet code and adapted with s/vnet/vdisk/. It would need the previously sent ldom.conf.5 vnet, although for correctness and consistency only. Feedback? OK? Index: config.c === RCS file: /cvs/src/usr.sbin/ldomctl/config.c,v retrieving revision 1.32 diff -u -p -r1.32 config.c --- config.c22 Jan 2020 07:52:38 - 1.32 +++ config.c5 Feb 2020 20:24:12 - @@ -2557,7 +2557,8 @@ guest_add_memory(struct guest *guest, ui } void -guest_add_vdisk(struct guest *guest, uint64_t id, const char *path) +guest_add_vdisk(struct guest *guest, uint64_t id, const char *path, +const char *user_devalias) { struct guest *primary; struct ldc_channel *lc; @@ -2577,6 +2578,8 @@ guest_add_vdisk(struct guest *guest, uin if (id == 0) guest_add_devalias(guest, "disk", devpath); guest_add_devalias(guest, devalias, devpath); + if (user_devalias != NULL) + guest_add_devalias(guest, user_devalias, devpath); free(devalias); free(devpath); } @@ -2849,7 +2852,8 @@ build_config(const char *filename, int n guest_add_memory(guest, -1, domain->memory); i = 0; SIMPLEQ_FOREACH(vdisk, &domain->vdisk_list, entry) - guest_add_vdisk(guest, i++, vdisk->path); + guest_add_vdisk(guest, i++, vdisk->path, + vdisk->devalias); i = 0; SIMPLEQ_FOREACH(vnet, &domain->vnet_list, entry) guest_add_vnetwork(guest, i++, vnet->mac_addr, Index: ldom.conf.5 === RCS file: /cvs/src/usr.sbin/ldomctl/ldom.conf.5,v retrieving revision 1.10 diff -u -p -r1.10 ldom.conf.5 --- ldom.conf.5 13 Jan 2020 09:29:41 - 1.10 +++ ldom.conf.5 5 Feb 2020 20:20:21 - @@ -56,7 +56,7 @@ See .Xr eeprom 8 for a list of OpenPROM variables. This keyword can be used multiple times. -.It Ic vdisk Ar file +.It Ic vdisk Ar file Op Ar keyword Ns = Ns Ar value ... The specified file is used to back a virtual disk of the guest domain. .Ar file @@ -64,6 +64,12 @@ can be a block device node or a disk ima .Cm create-vdisk command. This keyword can be used multiple times. +Valid options are: +.Bl -tag -width Ds +.It Ic devalias Ns = Ns Ar name +Alias the virtual disk as +.Ar name . +.El .It Ic vnet Op Brq Ar keyword Ns = Ns Ar value ... Assign a .Xr vnet 4 Index: ldomctl.h === RCS file: /cvs/src/usr.sbin/ldomctl/ldomctl.h,v retrieving revision 1.12 diff -u -p -r1.12 ldomctl.h --- ldomctl.h 4 Jan 2020 15:45:46 - 1.12 +++ ldomctl.h 5 Feb 2020 20:18:43 - @@ -158,6 +158,7 @@ extern uint64_t hv_memsize; struct vdisk { SIMPLEQ_ENTRY(vdisk)entry; const char *path; + const char *devalias; }; struct vnet { Index: parse.y === RCS file: /cvs/src/usr.sbin/ldomctl/parse.y,v retrieving revision 1.15 diff -u -p -r1.15 parse.y --- parse.y 9 Jan 2020 22:06:23 - 1.15 +++ parse.y 5 Feb 2020 20:18:48 - @@ -70,12 +70,17 @@ struct vcpu_opts { uint64_tstride; } vcpu_opts; +struct vdisk_opts { + const char *devalias; +} vdisk_opts; + struct vnet_opts { uint64_tmac_addr; uint64_tmtu; } vnet_opts; void vcput_opts_default(void); +void vdisk_opts_default(void); void vnet_opts_default(void); typedef struct { @@ -83,6 +88,7 @@ typedef struct { int64_t number; char*string; struct vcpu_opts vcpu_opts; + struct vdisk_optsvdisk_opts; struct