@@ -68,7 +68,13 @@ def set_imgargs(options):
6868 if options .sampler :
6969 execute = '--sampler=%d %s' % (int (options .sampler ), execute )
7070
71+ if options .hypervisor == 'qemu_microvm' :
72+ execute = '--nopci ' + execute
73+
7174 options .osv_cmdline = execute
75+ if options .kernel or options .hypervisor == 'qemu_microvm' :
76+ return
77+
7278 cmdline = [os .path .join (osv_base , "scripts/imgedit.py" ), "setargs" , options .image_file , execute ]
7379 if options .dry_run :
7480 print (format_args (cmdline ))
@@ -101,7 +107,7 @@ def start_osv_qemu(options):
101107 "-m" , options .memsize ,
102108 "-smp" , options .vcpus ]
103109
104- if not options .novnc :
110+ if not options .novnc and options . hypervisor != 'qemu_microvm' :
105111 args += [
106112 "-vnc" , options .vnc ]
107113 else :
@@ -116,15 +122,21 @@ def start_osv_qemu(options):
116122 args += [
117123 "-display" , "sdl" ]
118124
119- if options .kernel :
125+ if options .kernel or options . hypervisor == 'qemu_microvm' :
120126 boot_index = ""
121127 args += [
122128 "-kernel" , options .kernel_file ,
123129 "-append" , options .osv_cmdline ]
124130 else :
125131 boot_index = ",bootindex=0"
126132
127- if options .sata :
133+ if options .hypervisor == 'qemu_microvm' :
134+ args += [
135+ "-M" , "microvm,x-option-roms=off,pit=off,pic=off,rtc=off" ,
136+ "-nodefaults" , "-no-user-config" , "-no-reboot" , "-global" , "virtio-mmio.force-legacy=off" ,
137+ "-device" , "virtio-blk-device,id=blk0,drive=hd0,scsi=off%s%s" % (boot_index , options .virtio_device_suffix ),
138+ "-drive" , "file=%s,if=none,id=hd0,%s" % (options .image_file , aio )]
139+ elif options .sata :
128140 args += [
129141 "-machine" , "q35" ,
130142 "-drive" , "file=%s,if=none,id=hd0,media=disk,%s" % (options .image_file , aio ),
@@ -156,6 +168,8 @@ def start_osv_qemu(options):
156168 for idx in range (int (options .nics )):
157169 if options .vmxnet3 :
158170 net_device_options = ['vmxnet3' ]
171+ elif options .hypervisor == 'qemu_microvm' :
172+ net_device_options = ['virtio-net-device' ]
159173 else :
160174 net_device_options = ['virtio-net-pci' ]
161175
@@ -193,14 +207,17 @@ def start_osv_qemu(options):
193207
194208 args += ["-device" , net_device_options_str ]
195209
196- args += ["-device" , "virtio-rng-pci%s" % options .virtio_device_suffix ]
210+ if options .hypervisor != 'qemu_microvm' :
211+ args += ["-device" , "virtio-rng-pci%s" % options .virtio_device_suffix ]
197212
198- if options .hypervisor == "kvm" :
213+ if options .hypervisor == "kvm" or options . hypervisor == 'qemu_microvm' :
199214 args += ["-enable-kvm" , "-cpu" , "host,+x2apic" ]
200215 elif options .hypervisor == "none" or options .hypervisor == "qemu" :
201216 pass
202217
203- if options .detach :
218+ if options .hypervisor == 'qemu_microvm' :
219+ args += ["-serial" , "stdio" ]
220+ elif options .detach :
204221 args += ["-daemonize" ]
205222 else :
206223 signal_option = ('off' , 'on' )[options .with_signals ]
@@ -405,6 +422,7 @@ def start_osv(options):
405422 "xenpv" : start_osv_xen ,
406423 "none" : start_osv_qemu ,
407424 "qemu" : start_osv_qemu ,
425+ "qemu_microvm" : start_osv_qemu ,
408426 "kvm" : start_osv_qemu ,
409427 "vmware" : start_osv_vmware ,
410428 }
@@ -459,7 +477,7 @@ def main(options):
459477 parser .add_argument ("-e" , "--execute" , action = "store" , default = None , metavar = "CMD" ,
460478 help = "edit command line before execution" )
461479 parser .add_argument ("-p" , "--hypervisor" , action = "store" , default = "auto" ,
462- help = "choose hypervisor to run: kvm, xen, xenpv, vmware, none (plain qemu)" )
480+ help = "choose hypervisor to run: kvm, qemu_microvm, xen, xenpv, vmware, none (plain qemu)" )
463481 parser .add_argument ("-D" , "--detach" , action = "store_true" ,
464482 help = "run in background, do not connect the console" )
465483 parser .add_argument ("-H" , "--no-shutdown" , action = "store_true" ,
0 commit comments