Message ID | 20190125140017.6092-15-alex.bennee@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | testing/next (binfmt_misc, vm-build and BSD CI) | expand |
On Fri, Jan 25, 2019 at 02:00:17PM +0000, Alex Bennée wrote: > A lot of architectures can run their 32 bit cousins on KVM so the > kvm_available function needs to be a little less restricting when > deciding if KVM is available. > > Signed-off-by: Alex Bennée <alex.bennee@linaro.org> > --- > scripts/qemu.py | 11 ++++++++++- > 1 file changed, 10 insertions(+), 1 deletion(-) > > diff --git a/scripts/qemu.py b/scripts/qemu.py > index 0a5e02eb56..2934ee12c5 100644 > --- a/scripts/qemu.py > +++ b/scripts/qemu.py > @@ -25,9 +25,18 @@ import tempfile > > LOG = logging.getLogger(__name__) > > +# Mapping host architecture to any additional architectures it can > +# support which often includes its 32 bit cousin. > +ADDITIONAL_ARCHES = { > + "x86_64" : "i386", > + "aarch64" : "armhf" > +} > > def kvm_available(target_arch=None): > - if target_arch and target_arch != os.uname()[4]: > + host_arch = os.uname()[4] > + if target_arch and target_arch != host_arch: > + if target_arch == ADDITIONAL_ARCHES[host_arch]: This will crash host_arch isn't "x86_64" or "aarch64". I suggest ADDITIONAL_ARCHES.get(host_arch) > + return True I don't think we should skip the /dev/kvm check here. > return False > return os.access("/dev/kvm", os.R_OK | os.W_OK) > > -- > 2.17.1 > -- Eduardo
Good point. I should fall through. On Sat, 26 Jan 2019, 03:37 Eduardo Habkost <ehabkost@redhat.com wrote: > On Fri, Jan 25, 2019 at 02:00:17PM +0000, Alex Bennée wrote: > > A lot of architectures can run their 32 bit cousins on KVM so the > > kvm_available function needs to be a little less restricting when > > deciding if KVM is available. > > > > Signed-off-by: Alex Bennée <alex.bennee@linaro.org> > > --- > > scripts/qemu.py | 11 ++++++++++- > > 1 file changed, 10 insertions(+), 1 deletion(-) > > > > diff --git a/scripts/qemu.py b/scripts/qemu.py > > index 0a5e02eb56..2934ee12c5 100644 > > --- a/scripts/qemu.py > > +++ b/scripts/qemu.py > > @@ -25,9 +25,18 @@ import tempfile > > > > LOG = logging.getLogger(__name__) > > > > +# Mapping host architecture to any additional architectures it can > > +# support which often includes its 32 bit cousin. > > +ADDITIONAL_ARCHES = { > > + "x86_64" : "i386", > > + "aarch64" : "armhf" > > +} > > > > def kvm_available(target_arch=None): > > - if target_arch and target_arch != os.uname()[4]: > > + host_arch = os.uname()[4] > > + if target_arch and target_arch != host_arch: > > + if target_arch == ADDITIONAL_ARCHES[host_arch]: > > This will crash host_arch isn't "x86_64" or "aarch64". I suggest > ADDITIONAL_ARCHES.get(host_arch) > > > + return True > > I don't think we should skip the /dev/kvm check here. > > > > return False > > return os.access("/dev/kvm", os.R_OK | os.W_OK) > > > > -- > > 2.17.1 > > > > -- > Eduardo >
diff --git a/scripts/qemu.py b/scripts/qemu.py index 0a5e02eb56..2934ee12c5 100644 --- a/scripts/qemu.py +++ b/scripts/qemu.py @@ -25,9 +25,18 @@ import tempfile LOG = logging.getLogger(__name__) +# Mapping host architecture to any additional architectures it can +# support which often includes its 32 bit cousin. +ADDITIONAL_ARCHES = { + "x86_64" : "i386", + "aarch64" : "armhf" +} def kvm_available(target_arch=None): - if target_arch and target_arch != os.uname()[4]: + host_arch = os.uname()[4] + if target_arch and target_arch != host_arch: + if target_arch == ADDITIONAL_ARCHES[host_arch]: + return True return False return os.access("/dev/kvm", os.R_OK | os.W_OK)
A lot of architectures can run their 32 bit cousins on KVM so the kvm_available function needs to be a little less restricting when deciding if KVM is available. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> --- scripts/qemu.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.17.1