diff --git a/README.md b/README.md index 170a2c8..c5ff4b2 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/include/xhyve/support/uuid.h b/include/xhyve/support/uuid.h index 22e2da2..5d4c1f3 100644 --- a/include/xhyve/support/uuid.h +++ b/include/xhyve/support/uuid.h @@ -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); diff --git a/src/pci_virtio_vmnet.c b/src/pci_virtio_vmnet.c index 5177c15..b8d2f99 100644 --- a/src/pci_virtio_vmnet.c +++ b/src/pci_virtio_vmnet.c @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -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; diff --git a/xhyverun.sh b/xhyverun.sh index bb81523..5d2e147 100755 --- a/xhyverun.sh +++ b/xhyverun.sh @@ -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"