From f835243d7dd520fc3d46c6483747619b93b23d2a Mon Sep 17 00:00:00 2001 From: Ioseph Kim Date: Sun, 3 Apr 2022 03:58:54 +0900 Subject: [PATCH 1/3] add -r option (user defined mac address) original code generated random mac address. I patched to set user defined mac address. --- vftool/main.m | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/vftool/main.m b/vftool/main.m index 2e1f528..22f30ce 100644 --- a/vftool/main.m +++ b/vftool/main.m @@ -96,7 +96,8 @@ static int createPty(bool waitForConnection) NSString *initrd_path, struct disc_info *dinfo, unsigned int num_discs, - NSString *bridged_eth) + NSString *bridged_eth, + NSString *user_macaddr) { /* **************************************************************** */ /* Linux bootloader setup: @@ -179,6 +180,12 @@ static int createPty(bool waitForConnection) } VZVirtioNetworkDeviceConfiguration *net_conf = [[VZVirtioNetworkDeviceConfiguration alloc] init]; + // set user defined mac address + if (user_macaddr) { + VZMACAddress *nma = nil; + nma = [[VZMACAddress alloc] initWithString:user_macaddr]; + [(VZVirtioNetworkDeviceConfiguration *)net_conf setMACAddress:[(VZMACAddress *)nma copy]]; + } [net_conf setAttachment:nda]; [conf setNetworkDevices:@[net_conf]]; @@ -228,6 +235,7 @@ static void usage(const char *me) "\t-p (Default 1)\n" "\t-m (Default 512MB)\n" "\t-t (0 = stdio, 1 = pty (default))\n" + "\t-r (Default random)\n" "\n\tSpecify multiple discs with multiple -d/-c options, in order (max %d)\n", me, MAX_DISCS); } @@ -242,6 +250,7 @@ int main(int argc, char *argv[]) NSString *disc_path = NULL; NSString *cdrom_path = NULL; NSString *eth_if = NULL; + NSString *user_macaddr = NULL; unsigned int cpus = 0; unsigned int mem = 0; unsigned int tty_type = 1; @@ -250,7 +259,7 @@ int main(int argc, char *argv[]) unsigned int num_discs = 0; int ch; - while ((ch = getopt(argc, argv, "k:a:i:d:c:b:p:m:t:h")) != -1) { + while ((ch = getopt(argc, argv, "k:a:i:d:c:b:p:m:t:r:h")) != -1) { switch (ch) { case 'k': kern_path = [NSString stringWithUTF8String:optarg]; @@ -289,7 +298,10 @@ int main(int argc, char *argv[]) return 1; } break; - + case 'r': + user_macaddr = [NSString stringWithUTF8String:optarg]; + break; + case 'h': default: usage(argv[0]); @@ -323,7 +335,7 @@ int main(int argc, char *argv[]) VZVirtualMachineConfiguration *conf = getVMConfig(mem, cpus, tty_type, cmdline, kern_path, initrd_path, dinfo, num_discs, - eth_if); + eth_if, user_macaddr); if (!conf) { NSLog(@"Couldn't create configuration for VM.\n"); From 46f8dda327dd2d2e7a4b4138652bfdda2c6e37a7 Mon Sep 17 00:00:00 2001 From: Ioseph Kim Date: Tue, 24 May 2022 15:56:47 +0900 Subject: [PATCH 2/3] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 799164b..69ec961 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +# https://www.katacoda.com/crunchydata/courses/postgis/geometries + # Virtualization.framework tool (vftool) Here lies a _really minimalist_ and very noddy command-line wrapper to run VMs in the macOS Big Sur Virtualization.framework. From 7fa96d3c383553d86a8405494c94d193c5fd5220 Mon Sep 17 00:00:00 2001 From: Ioseph Kim Date: Thu, 30 Jan 2025 23:46:04 +0900 Subject: [PATCH 3/3] Update README.md --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 69ec961..799164b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -# https://www.katacoda.com/crunchydata/courses/postgis/geometries - # Virtualization.framework tool (vftool) Here lies a _really minimalist_ and very noddy command-line wrapper to run VMs in the macOS Big Sur Virtualization.framework.