-/* $OpenBSD: config.c,v 1.23 2018/09/16 12:17:05 kettenis Exp $ */
+/* $OpenBSD: config.c,v 1.24 2018/09/16 14:27:32 kettenis Exp $ */
/*
- * Copyright (c) 2012 Mark Kettenis
+ * Copyright (c) 2012, 2018 Mark Kettenis
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
free(devpath);
}
+void
+guest_add_variable(struct guest *guest, const char *name, const char *str)
+{
+ struct md *md = guest->md;
+ struct md_node *parent;
+ struct md_node *node;
+
+ node = md_find_node(md, "variables");
+ if (node == NULL) {
+ parent = md_find_node(md, "root");
+ assert(parent);
+
+ node = md_add_node(md, "variables");
+ md_link_node(md, parent, node);
+ }
+
+ md_add_prop_str(md, node, name, str);
+}
+
struct cpu *
guest_find_cpu(struct guest *guest, uint64_t pid)
{
struct domain *domain;
struct vdisk *vdisk;
struct vnet *vnet;
+ struct var *var;
uint64_t num_cpus, primary_num_cpus;
uint64_t memory, primary_memory;
guest_delete_memory(primary);
guest_add_memory(primary, -1, primary_memory);
+ SIMPLEQ_FOREACH(domain, &conf.domain_list, entry) {
+ if (strcmp(domain->name, "primary") != 0)
+ continue;
+ SIMPLEQ_FOREACH(var, &domain->var_list, entry)
+ guest_add_variable(primary, var->name, var->str);
+ }
+
SIMPLEQ_FOREACH(domain, &conf.domain_list, entry) {
if (strcmp(domain->name, "primary") == 0)
continue;
SIMPLEQ_FOREACH(vnet, &domain->vnet_list, entry)
guest_add_vnetwork(guest, i++, vnet->mac_addr,
vnet->mtu);
+ SIMPLEQ_FOREACH(var, &domain->var_list, entry)
+ guest_add_variable(guest, var->name, var->str);
guest_finalize(guest);
}
-.\" $OpenBSD: ldomctl.8,v 1.10 2018/04/09 10:15:15 kn Exp $
+.\" $OpenBSD: ldomctl.8,v 1.11 2018/09/16 14:27:32 kettenis Exp $
.\"
.\" Copyright (c) 2012 Mark Kettenis <kettenis@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 9 2018 $
+.Dd $Mdocdate: September 16 2018 $
.Dt LDOMCTL 8 sparc64
.Os
.Sh NAME
Declares the amount of memory assigned to a domain, in bytes.
Optionally, the units 'K', 'M', or 'G', for kilo-, mega-, and gigabytes
can be used.
+.It Ic variable Ar name Ic = Ar value
+Sets the specified NVRAM variable for the domain.
.It Ic vdisk Ar file
The specified file is used to back a virtual disk of the guest
domain.
can be a block device node or a disk image file created with
.Xr dd 1 .
This keyword can be used multiple times.
-.It Ic vnet Op Ic \&{ Ar keyword value ... Ic \&}
+.It Ic vnet Op Ic \&{ Ar keyword Ic = Ar value ... Ic \&}
Assign a
.Xr vnet 4
network interface to the guest domain.
-/* $OpenBSD: ldomctl.h,v 1.6 2018/09/16 12:17:05 kettenis Exp $ */
+/* $OpenBSD: ldomctl.h,v 1.7 2018/09/16 14:27:32 kettenis Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis
uint64_t mtu;
};
+struct var {
+ SIMPLEQ_ENTRY(var) entry;
+ const char *name;
+ const char *str;
+};
+
struct domain {
SIMPLEQ_ENTRY(domain) entry;
const char *name;
uint64_t memory;
SIMPLEQ_HEAD(, vdisk) vdisk_list;
SIMPLEQ_HEAD(, vnet) vnet_list;
+ SIMPLEQ_HEAD(, var) var_list;
} *domain;
struct ldom_config {
-/* $OpenBSD: parse.y,v 1.7 2018/07/09 12:05:11 krw Exp $ */
+/* $OpenBSD: parse.y,v 1.8 2018/09/16 14:27:32 kettenis Exp $ */
/*
* Copyright (c) 2012 Mark Kettenis <kettenis@openbsd.org>
%}
%token DOMAIN
-%token VCPU MEMORY VDISK VNET
+%token VCPU MEMORY VDISK VNET VARIABLE
%token MAC_ADDR MTU
%token ERROR
%token <v.string> STRING
domain->name = $2;
SIMPLEQ_INIT(&domain->vdisk_list);
SIMPLEQ_INIT(&domain->vnet_list);
+ SIMPLEQ_INIT(&domain->var_list);
}
domainopts_l '}' {
/* domain names need to be unique. */
vnet->mtu = $2.mtu;
SIMPLEQ_INSERT_TAIL(&domain->vnet_list, vnet, entry);
}
+ | VARIABLE STRING '=' STRING {
+ struct var *var = xmalloc(sizeof(struct var));
+ var->name = $2;
+ var->str = $4;
+ SIMPLEQ_INSERT_TAIL(&domain->var_list, var, entry);
+ }
;
vnet_opts : { opts_default(); }
{ "mac-addr", MAC_ADDR},
{ "memory", MEMORY},
{ "mtu", MTU},
+ { "variable", VARIABLE},
{ "vcpu", VCPU},
{ "vdisk", VDISK},
{ "vnet", VNET}