qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 7/8] tests/vm: Added a new script for ubuntu.aarch64.


From: Robert Foley
Subject: Re: [PATCH 7/8] tests/vm: Added a new script for ubuntu.aarch64.
Date: Mon, 27 Jan 2020 11:47:35 -0500

On Mon, 27 Jan 2020 at 10:01, Alex Bennée <address@hidden> wrote:
> >  vm-boot-ssh-%: $(IMAGES_DIR)/%.img
> >       $(call quiet-command, \
> > -             $(SRC_PATH)/tests/vm/$* \
> > +             $(PYTHON) $(SRC_PATH)/tests/vm/$* \
>
> This seems like it should be in a different patch.

Good point, will move it to a different patch.

> > +
> > +DEFAULT_CONFIG = {
> > +    'cpu'          : "max",
> > +    'machine'      : "virt,gic-version=max",
>
> According to virt.c:
>
>   Valid values are 2, 3 and host
>
> but max should work on TCG. However we need a more recent QEMU than my
> system one for it to work. Otherwise you see:
>
>   DEBUG:qemu.machine:Error launching VM

Good point.  We were trying to avoid having different values for KVM
vs TCG, which we
could do with the latest QEMU.
We will update this to make sure this works with older versions of QEMU as well.

On my system I have qemu 2.11.1 installed by default.
It seems that we will need the following defaults based on our environment.

For KVM we end up with the below args since max cpu and max
gic-version is not available.
kvm:  -cpu host -machine virt,gic-version=host

For TCG max cpu is also not available: qemu-system-aarch64: unable to
find CPU model 'max',
so we pick cortex-a57.
TCG: -cpu cortex-a57 -machine virt,gic-version=3

I suppose we could check the version of QEMU and use the above
defaults only for earlier versions of QEMU.
This is something we will probably move to aarch64vm.py since it is common.

> > +class UbuntuAarch64VM(basevm.BaseVM):
> > +    name = "ubuntu.aarch64"
> > +    arch = "aarch64"
> > +    image_name = "ubuntu-18.04-server-cloudimg-arm64.img"
> > +    image_link = "https://cloud-images.ubuntu.com/releases/18.04/release/"; 
> > + image_name
> > +    login_prompt = "ubuntu-guest login:"
> > +    BUILD_SCRIPT = """
> > +        set -e;
> > +        cd $(mktemp -d);
> > +        sudo chmod a+r /dev/vdb;
> > +        tar --checkpoint=.10 -xf /dev/vdb;
> > +        ./configure {configure_opts};
> > +        make --output-sync {target} -j{jobs} {verbose};
> > +    """
> > +    def _gen_cloud_init_iso(self):
__snip__
> > +
> > +        return os.path.join(cidir, "cloud-init.iso")
>
> It seems this function is proliferating. It certainly seems common
> enough to be basevm functionality.

Makes sense.  Will look at making this common to basevm.

>
> > +
> > +    def boot(self, img, extra_args=None):
> > +        aarch64vm.create_flash_images()
> > +        default_args = aarch64vm.get_pflash_args()
> > +        if extra_args:
> > +            extra_args.extend(default_args)
> > +        else:
> > +            extra_args = default_args
> > +        # We always add these performance tweaks
> > +        # because without them, we boot so slowly that we
> > +        # can time out finding the boot efi device.
> > +        if os.geteuid() != 0:
> > +            extra_args.extend(["-accel", "tcg,thread=multi"])
>
> Hmmm thread=multi should already be enabled by default where it is safe
> to do so. Also what has it to do with euid?

OK.  Will look into removing this.
We were trying to check for KVM, to only add this under KVM.
I see now, we need to use kvm_available() instead of euid.

Thanks & Regards,
-Rob


>
> > +        if '-smp' not in extra_args and \
> > +           '-smp' not in self._config['extra_args'] and \
> > +           '-smp' not in self._args:
> > +            # Only add if not already there to give caller option to 
> > change it.
> > +            extra_args.extend(["-smp", "8"])
> > +
> > +        # We have overridden boot() since aarch64 has additional 
> > parameters.
> > +        # Call down to the base class method.
> > +        super(UbuntuAarch64VM, self).boot(img, extra_args=extra_args)
> > +
> > +    def build_image(self, img):
> > +        os_img = self._download_with_cache(self.image_link)
> > +        img_tmp = img + ".tmp"
> > +        subprocess.check_call(["cp", "-f", os_img, img_tmp])
> > +        subprocess.check_call(["qemu-img", "resize", img_tmp, "+50G"])
> > +        ci_img = self._gen_cloud_init_iso()
> > +
> > +        self.boot(img_tmp, extra_args = ["-cdrom", ci_img])
> > +        self.wait_ssh(wait_root=True)
> > +        # Fix for slow ssh login.
> > +        self.ssh_root("chmod -x /etc/update-motd.d/*")
> > +        self.ssh_root("touch /etc/cloud/cloud-init.disabled")
> > +        # Disable auto upgrades.
> > +        # We want to keep the VM system state stable.
> > +        self.ssh_root('sed -ie \'s/"1"/"0"/g\' 
> > /etc/apt/apt.conf.d/20auto-upgrades')
> > +
> > +        # If the user chooses *not* to do the second phase,
> > +        # then we will jump right to the graceful shutdown
> > +        if self._config['install_cmds'] != "":
> > +            # Don't check the status in case the guest hang up too quickly
> > +            self.ssh_root("sync && reboot")
> > +
> > +            self.wait_ssh(wait_root=True)
> > +            # The previous update sometimes doesn't survive a reboot, so 
> > do it again
> > +            self.ssh_root("sed -ie s/^#\ deb-src/deb-src/g 
> > /etc/apt/sources.list")
> > +
> > +            # Issue the install commands.
> > +            # This can be overriden by the user in the config .yml.
> > +            install_cmds = self._config['install_cmds'].split(',')
> > +            for cmd in install_cmds:
> > +                self.ssh_root(cmd)
> > +        self.graceful_shutdown()
> > +        self.wait()
> > +        os.rename(img_tmp, img)
> > +        return 0
> > +
> > +if __name__ == "__main__":
> > +    sys.exit(basevm.main(UbuntuAarch64VM, DEFAULT_CONFIG))
>
>
> --
> Alex Bennée



reply via email to

[Prev in Thread] Current Thread [Next in Thread]