Re: [osv-dev] [PATCH] scripts: enhance run.py to allow running OSv on arm

2020-02-24 Thread Waldek Kozaczuk
As you pointed out there are still many issues with supporting ARM by 
run.py. I will be improving it as we go.

On Sunday, February 23, 2020 at 3:31:19 AM UTC-5, Nadav Har'El wrote:
>
> I'll commit, but have some questions below, for future improvements.
>
> --
> Nadav Har'El
> n...@scylladb.com 
>
>
> On Sat, Feb 22, 2020 at 11:13 PM Waldemar Kozaczuk  > wrote:
>
>> Signed-off-by: Waldemar Kozaczuk >
>> ---
>>  scripts/run.py | 53 +-
>>  1 file changed, 39 insertions(+), 14 deletions(-)
>>
>> diff --git a/scripts/run.py b/scripts/run.py
>> index f4452345..5a86c297 100755
>> --- a/scripts/run.py
>> +++ b/scripts/run.py
>> @@ -71,8 +71,11 @@ def set_imgargs(options):
>>  if options.hypervisor == 'qemu_microvm':
>>  execute = '--nopci ' + execute
>>
>> +if options.arch == 'aarch64':
>> +execute = '--nomount --maxnic=0 ' + execute #TODO: Investigate 
>> why both virtio-blk and virtio-net does not seem to work
>> +
>>  options.osv_cmdline = execute
>> -if options.kernel or options.hypervisor == 'qemu_microvm':
>> +if options.kernel or options.hypervisor == 'qemu_microvm' or 
>> options.arch == 'aarch64':
>>  return
>>
>>  cmdline = [os.path.join(osv_base, "scripts/imgedit.py"), "setargs", 
>> options.image_file, execute]
>> @@ -103,11 +106,16 @@ def start_osv_qemu(options):
>>  else:
>>  aio = 'cache=none,aio=native'
>>
>> -args = [
>> -"-m", options.memsize,
>> -"-smp", options.vcpus]
>> +if options.arch == 'aarch64':
>> +args = [
>> +"-m", "1G",
>> +"-smp", "2"]
>>
>
> This is strange, why for aarch64 you cannot obey the regular memsize and 
> vcpus option and silently ignore them?
>
> +else:
>> +args = [
>> +"-m", options.memsize,
>> +"-smp", options.vcpus]
>>
>> -if not options.novnc and options.hypervisor != 'qemu_microvm':
>> +if not options.novnc and options.hypervisor != 'qemu_microvm' and 
>> options.arch == 'x86_64':
>>  args += [
>>  "-vnc", options.vnc]
>>  else:
>> @@ -122,7 +130,7 @@ def start_osv_qemu(options):
>>  args += [
>>  "-display", "sdl"]
>>
>> -if options.kernel or options.hypervisor == 'qemu_microvm':
>> +if options.kernel or options.hypervisor == 'qemu_microvm' or 
>> options.arch == 'aarch64':
>>  boot_index = ""
>>  args += [
>>  "-kernel", options.kernel_file,
>> @@ -130,7 +138,12 @@ def start_osv_qemu(options):
>>  else:
>>  boot_index = ",bootindex=0"
>>
>> -if options.hypervisor == 'qemu_microvm':
>> +if options.arch == 'aarch64':
>> +args += [
>> +"-machine", "virt", "-machine", "gic-version=2", "-cpu", 
>> "cortex-a57",
>> +"-device", "virtio-blk-device,id=blk0,drive=hd0,scsi=off%s%s" % 
>> (boot_index, options.virtio_device_suffix),
>> +"-drive", "file=%s,if=none,id=hd0,%s" % (options.image_file, 
>> aio)]
>> +elif options.hypervisor == 'qemu_microvm':
>>  args += [
>>  "-M", "microvm,x-option-roms=off,pit=off,pic=off,rtc=off",
>>  "-nodefaults", "-no-user-config", "-no-reboot", "-global", 
>> "virtio-mmio.force-legacy=off",
>> @@ -219,11 +232,13 @@ def start_osv_qemu(options):
>>  args += ["-serial", "stdio"]
>>  elif options.detach:
>>  args += ["-daemonize"]
>> -else:
>> +elif options.arch == 'x86_64':
>>  signal_option = ('off', 'on')[options.with_signals]
>>  args += ["-chardev", "stdio,mux=on,id=stdio,signal=%s" % 
>> signal_option]
>>  args += ["-mon", "chardev=stdio,mode=readline"]
>>  args += ["-device", "isa-serial,chardev=stdio"]
>> +else:
>> +pass
>>
>>  for a in options.pass_args or []:
>>  args += a.split()
>> @@ -236,7 +251,11 @@ def start_osv_qemu(options):
>>  qemu_env = os.environ.copy()
>>
>>  qemu_env['OSV_BRIDGE'] = options.bridge
>> -cmdline = [options.qemu_path] + args
>> +if options.arch == 'aarch64':
>> +qemu_path = 'qemu-system-aarch64'
>> +else:
>> +qemu_path = options.qemu_path
>> +cmdline = [qemu_path] + args
>>  if options.dry_run:
>>  print(format_args(cmdline))
>>  else:
>> @@ -245,7 +264,7 @@ def start_osv_qemu(options):
>>  sys.exit("qemu failed.")
>>  except OSError as e:
>>  if e.errno == errno.ENOENT:
>> -print("'qemu-system-x86_64' binary not found. Please install 
>> the qemu-system-x86 package.")
>> +print("'%s' binary not found. Please install the 
>> qemu-system-x86 package." % qemu_path)
>>
>
> The name of the package you are suggesting to install should also differ 
> for the different binary...
>
>  else:
>>  print("OS error({0}): \"{1}\" while running 
>> qemu-system-x86_64 {2}".
>>  format(e.errno, e.strerror, 

Re: [osv-dev] [PATCH] scripts: enhance run.py to allow running OSv on arm

2020-02-23 Thread Nadav Har'El
I'll commit, but have some questions below, for future improvements.

--
Nadav Har'El
n...@scylladb.com


On Sat, Feb 22, 2020 at 11:13 PM Waldemar Kozaczuk 
wrote:

> Signed-off-by: Waldemar Kozaczuk 
> ---
>  scripts/run.py | 53 +-
>  1 file changed, 39 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/run.py b/scripts/run.py
> index f4452345..5a86c297 100755
> --- a/scripts/run.py
> +++ b/scripts/run.py
> @@ -71,8 +71,11 @@ def set_imgargs(options):
>  if options.hypervisor == 'qemu_microvm':
>  execute = '--nopci ' + execute
>
> +if options.arch == 'aarch64':
> +execute = '--nomount --maxnic=0 ' + execute #TODO: Investigate
> why both virtio-blk and virtio-net does not seem to work
> +
>  options.osv_cmdline = execute
> -if options.kernel or options.hypervisor == 'qemu_microvm':
> +if options.kernel or options.hypervisor == 'qemu_microvm' or
> options.arch == 'aarch64':
>  return
>
>  cmdline = [os.path.join(osv_base, "scripts/imgedit.py"), "setargs",
> options.image_file, execute]
> @@ -103,11 +106,16 @@ def start_osv_qemu(options):
>  else:
>  aio = 'cache=none,aio=native'
>
> -args = [
> -"-m", options.memsize,
> -"-smp", options.vcpus]
> +if options.arch == 'aarch64':
> +args = [
> +"-m", "1G",
> +"-smp", "2"]
>

This is strange, why for aarch64 you cannot obey the regular memsize and
vcpus option and silently ignore them?

+else:
> +args = [
> +"-m", options.memsize,
> +"-smp", options.vcpus]
>
> -if not options.novnc and options.hypervisor != 'qemu_microvm':
> +if not options.novnc and options.hypervisor != 'qemu_microvm' and
> options.arch == 'x86_64':
>  args += [
>  "-vnc", options.vnc]
>  else:
> @@ -122,7 +130,7 @@ def start_osv_qemu(options):
>  args += [
>  "-display", "sdl"]
>
> -if options.kernel or options.hypervisor == 'qemu_microvm':
> +if options.kernel or options.hypervisor == 'qemu_microvm' or
> options.arch == 'aarch64':
>  boot_index = ""
>  args += [
>  "-kernel", options.kernel_file,
> @@ -130,7 +138,12 @@ def start_osv_qemu(options):
>  else:
>  boot_index = ",bootindex=0"
>
> -if options.hypervisor == 'qemu_microvm':
> +if options.arch == 'aarch64':
> +args += [
> +"-machine", "virt", "-machine", "gic-version=2", "-cpu",
> "cortex-a57",
> +"-device", "virtio-blk-device,id=blk0,drive=hd0,scsi=off%s%s" %
> (boot_index, options.virtio_device_suffix),
> +"-drive", "file=%s,if=none,id=hd0,%s" % (options.image_file, aio)]
> +elif options.hypervisor == 'qemu_microvm':
>  args += [
>  "-M", "microvm,x-option-roms=off,pit=off,pic=off,rtc=off",
>  "-nodefaults", "-no-user-config", "-no-reboot", "-global",
> "virtio-mmio.force-legacy=off",
> @@ -219,11 +232,13 @@ def start_osv_qemu(options):
>  args += ["-serial", "stdio"]
>  elif options.detach:
>  args += ["-daemonize"]
> -else:
> +elif options.arch == 'x86_64':
>  signal_option = ('off', 'on')[options.with_signals]
>  args += ["-chardev", "stdio,mux=on,id=stdio,signal=%s" %
> signal_option]
>  args += ["-mon", "chardev=stdio,mode=readline"]
>  args += ["-device", "isa-serial,chardev=stdio"]
> +else:
> +pass
>
>  for a in options.pass_args or []:
>  args += a.split()
> @@ -236,7 +251,11 @@ def start_osv_qemu(options):
>  qemu_env = os.environ.copy()
>
>  qemu_env['OSV_BRIDGE'] = options.bridge
> -cmdline = [options.qemu_path] + args
> +if options.arch == 'aarch64':
> +qemu_path = 'qemu-system-aarch64'
> +else:
> +qemu_path = options.qemu_path
> +cmdline = [qemu_path] + args
>  if options.dry_run:
>  print(format_args(cmdline))
>  else:
> @@ -245,7 +264,7 @@ def start_osv_qemu(options):
>  sys.exit("qemu failed.")
>  except OSError as e:
>  if e.errno == errno.ENOENT:
> -print("'qemu-system-x86_64' binary not found. Please install
> the qemu-system-x86 package.")
> +print("'%s' binary not found. Please install the
> qemu-system-x86 package." % qemu_path)
>

The name of the package you are suggesting to install should also differ
for the different binary...

 else:
>  print("OS error({0}): \"{1}\" while running
> qemu-system-x86_64 {2}".
>  format(e.errno, e.strerror, " ".join(args)))
> @@ -432,8 +451,8 @@ def start_osv(options):
>  print("Unrecognized hypervisor selected", file=sys.stderr)
>  return
>
> -def choose_hypervisor(external_networking):
> -if os.path.exists('/dev/kvm'):
> +def choose_hypervisor(external_networking, arch):
> +if os.path.exists('/dev/kvm') and arch == 'x86_64':
>  

[osv-dev] [PATCH] scripts: enhance run.py to allow running OSv on arm

2020-02-22 Thread Waldemar Kozaczuk
Signed-off-by: Waldemar Kozaczuk 
---
 scripts/run.py | 53 +-
 1 file changed, 39 insertions(+), 14 deletions(-)

diff --git a/scripts/run.py b/scripts/run.py
index f4452345..5a86c297 100755
--- a/scripts/run.py
+++ b/scripts/run.py
@@ -71,8 +71,11 @@ def set_imgargs(options):
 if options.hypervisor == 'qemu_microvm':
 execute = '--nopci ' + execute
 
+if options.arch == 'aarch64':
+execute = '--nomount --maxnic=0 ' + execute #TODO: Investigate why 
both virtio-blk and virtio-net does not seem to work
+
 options.osv_cmdline = execute
-if options.kernel or options.hypervisor == 'qemu_microvm':
+if options.kernel or options.hypervisor == 'qemu_microvm' or options.arch 
== 'aarch64':
 return
 
 cmdline = [os.path.join(osv_base, "scripts/imgedit.py"), "setargs", 
options.image_file, execute]
@@ -103,11 +106,16 @@ def start_osv_qemu(options):
 else:
 aio = 'cache=none,aio=native'
 
-args = [
-"-m", options.memsize,
-"-smp", options.vcpus]
+if options.arch == 'aarch64':
+args = [
+"-m", "1G",
+"-smp", "2"]
+else:
+args = [
+"-m", options.memsize,
+"-smp", options.vcpus]
 
-if not options.novnc and options.hypervisor != 'qemu_microvm':
+if not options.novnc and options.hypervisor != 'qemu_microvm' and 
options.arch == 'x86_64':
 args += [
 "-vnc", options.vnc]
 else:
@@ -122,7 +130,7 @@ def start_osv_qemu(options):
 args += [
 "-display", "sdl"]
 
-if options.kernel or options.hypervisor == 'qemu_microvm':
+if options.kernel or options.hypervisor == 'qemu_microvm' or options.arch 
== 'aarch64':
 boot_index = ""
 args += [
 "-kernel", options.kernel_file,
@@ -130,7 +138,12 @@ def start_osv_qemu(options):
 else:
 boot_index = ",bootindex=0"
 
-if options.hypervisor == 'qemu_microvm':
+if options.arch == 'aarch64':
+args += [
+"-machine", "virt", "-machine", "gic-version=2", "-cpu", "cortex-a57",
+"-device", "virtio-blk-device,id=blk0,drive=hd0,scsi=off%s%s" % 
(boot_index, options.virtio_device_suffix),
+"-drive", "file=%s,if=none,id=hd0,%s" % (options.image_file, aio)]
+elif options.hypervisor == 'qemu_microvm':
 args += [
 "-M", "microvm,x-option-roms=off,pit=off,pic=off,rtc=off",
 "-nodefaults", "-no-user-config", "-no-reboot", "-global", 
"virtio-mmio.force-legacy=off",
@@ -219,11 +232,13 @@ def start_osv_qemu(options):
 args += ["-serial", "stdio"]
 elif options.detach:
 args += ["-daemonize"]
-else:
+elif options.arch == 'x86_64':
 signal_option = ('off', 'on')[options.with_signals]
 args += ["-chardev", "stdio,mux=on,id=stdio,signal=%s" % signal_option]
 args += ["-mon", "chardev=stdio,mode=readline"]
 args += ["-device", "isa-serial,chardev=stdio"]
+else:
+pass
 
 for a in options.pass_args or []:
 args += a.split()
@@ -236,7 +251,11 @@ def start_osv_qemu(options):
 qemu_env = os.environ.copy()
 
 qemu_env['OSV_BRIDGE'] = options.bridge
-cmdline = [options.qemu_path] + args
+if options.arch == 'aarch64':
+qemu_path = 'qemu-system-aarch64'
+else:
+qemu_path = options.qemu_path
+cmdline = [qemu_path] + args
 if options.dry_run:
 print(format_args(cmdline))
 else:
@@ -245,7 +264,7 @@ def start_osv_qemu(options):
 sys.exit("qemu failed.")
 except OSError as e:
 if e.errno == errno.ENOENT:
-print("'qemu-system-x86_64' binary not found. Please install the 
qemu-system-x86 package.")
+print("'%s' binary not found. Please install the qemu-system-x86 
package." % qemu_path)
 else:
 print("OS error({0}): \"{1}\" while running qemu-system-x86_64 
{2}".
 format(e.errno, e.strerror, " ".join(args)))
@@ -432,8 +451,8 @@ def start_osv(options):
 print("Unrecognized hypervisor selected", file=sys.stderr)
 return
 
-def choose_hypervisor(external_networking):
-if os.path.exists('/dev/kvm'):
+def choose_hypervisor(external_networking, arch):
+if os.path.exists('/dev/kvm') and arch == 'x86_64':
 return 'kvm'
 if (os.path.exists('/proc/xen/capabilities')
 and 'control_d' in file('/proc/xen/capabilities').read()
@@ -531,10 +550,16 @@ if __name__ == "__main__":
 help="Run OSv in QEMU kernel mode as PVH.")
 parser.add_argument("--virtio", action="store", 
choices=["legacy","transitional","modern"], default="transitional",
 help="specify virtio version: legacy, transitional or 
modern")
+parser.add_argument("--arch", action="store", 
choices=["x86_64","aarch64"], default="x86_64",
+