Merge pull request #20 from xez/vmnet-uuid

vmnet "static" IP support: assign UUID per VM
This commit is contained in:
Michael Steil 2015-06-13 10:56:30 -07:00
commit 49757e543f
4 changed files with 21 additions and 3 deletions

View file

@ -150,6 +150,12 @@ xhyve shares most of the code with bhyve but is architecturally very different.
*bhyvectl*, *bhyveload* and *grub2-bhyve* are incompatible with a single process model and are dropped. As a stop-gap solution until we have a proper firmware xhyve supports the Linux [kexec protocol](http://www.kernel.org/doc/Documentation/x86/boot.txt), a very simple and straightforward way to bootstrap a Linux kernel. It takes a bzImage and optionally initrd image and kernel parameter string as input.
Networking
------
If you want the same IP address across VM reboots, assign a UUID to a particular VM:
$ xhyve [-U uuid]
Issues
------
Right now, if you have (any version of) VirtualBox running and attempt to run

View file

@ -75,7 +75,7 @@ uuid_create_nil(uuid_t *u, uint32_t *status)
bzero(u, sizeof(*u));
}
static void
static inline void
uuid_enc_le(void *buf, uuid_t *uuid)
{
uuid_internal_t *u = (uuid_internal_t *) ((void *) uuid);

View file

@ -69,6 +69,7 @@
#include <xhyve/support/atomic.h>
#include <xhyve/support/linker_set.h>
#include <xhyve/support/md5.h>
#include <xhyve/support/uuid.h>
#include <xhyve/xhyve.h>
#include <xhyve/pci_emul.h>
#include <xhyve/mevent.h>
@ -209,11 +210,21 @@ vmn_create(struct pci_vtnet_softc *sc)
dispatch_queue_t if_create_q;
dispatch_queue_t if_q;
struct vmnet_state *vms;
uint32_t uuid_status;
interface_desc = xpc_dictionary_create(NULL, NULL, 0);
xpc_dictionary_set_uint64(interface_desc, vmnet_operation_mode_key,
VMNET_SHARED_MODE);
uuid_generate_random(uuid);
if (guest_uuid_str != NULL) {
uuid_from_string(guest_uuid_str, &uuid, &uuid_status);
if (uuid_status != uuid_s_ok) {
return (NULL);
}
} else {
uuid_generate_random(uuid);
}
xpc_dictionary_set_uuid(interface_desc, vmnet_interface_id_key, uuid);
iface = NULL;
iface_status = 0;

View file

@ -11,5 +11,6 @@ MEM="-m 1G"
#IMG_HDD="-s 4,virtio-blk,/somepath/somefile.img"
PCI_DEV="-s 0:0,hostbridge -s 31,lpc"
LPC_DEV="-l com1,stdio"
#UUID="-U deadbeef-dead-dead-dead-deaddeafbeef"
build/xhyve $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD -f kexec,$KERNEL,$INITRD,"$CMDLINE"
build/xhyve $MEM $SMP $PCI_DEV $LPC_DEV $NET $IMG_CD $IMG_HDD $UUID -f kexec,$KERNEL,$INITRD,"$CMDLINE"