qemu: Only one element of qemuPaths map is relevant

The qemuPaths field in qemuArchBase maps from machine type to the default
qemu path.  But, by the time we construct it, we already know the machine
type, so that entry ends up being the only one we care about.

So, collapse the map into a single path.  As a bonus, the qemuPath()
method can no longer fail.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
David Gibson
2020-06-20 20:04:49 +10:00
parent 5dffffd432
commit ea1d799f79
8 changed files with 12 additions and 50 deletions

View File

@@ -346,9 +346,7 @@ func TestQemuQemuPath(t *testing.T) {
Type: "pc",
Options: "",
},
qemuPaths: map[string]string{
"pc": expectedPath,
},
qemuExePath: expectedPath,
}
q := &qemu{
@@ -372,13 +370,6 @@ func TestQemuQemuPath(t *testing.T) {
path, err = q.qemuPath()
assert.NoError(err)
assert.Equal(path, expectedPath)
// bad machine type, arch should fail
qkvm.qemuMachine.Type = "rgb"
q.arch = qkvm
path, err = q.qemuPath()
assert.Error(err)
assert.Equal(path, "")
}
func TestHotplugUnsupportedDeviceType(t *testing.T) {