Commit Graph

8194 Commits

Author SHA1 Message Date
Samuel Ortiz
eae8fae0e7 qemu: Fix security model typo
The right qemu parameter is "security_model", not "security-model".

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-21 17:48:47 +02:00
Samuel Ortiz
db067857bd qemu: Make Config's FDs field private
All file descriptors will come from specific devices configurations, so
this patch:

1) Make the Config FDs file private
2) Provide an appendFDs() method for Config, that takes a slice of
os.File pointers and
   a) Adds them to the Config private fd slice
   b) Return a slice of ints that represent the file descriptors for
      these device specific files, as seen by the qemu process.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-19 12:43:03 +02:00
Samuel Ortiz
12f6ebe389 qemu: Embed the qemu parameters into the Config structure
It is a private field now, and all append*() routines are now
Config methods instead of private qemu functions.

Since we will have to carry a kernelParams private field as well,
this change will keep all built parameters internal and make things
consistent.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-19 12:41:40 +02:00
Samuel Ortiz
e193a77b8d qemu: Add support for block devices
For now we only support QCOW2 backed block devices.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 01:08:31 +02:00
Samuel Ortiz
3908185ccd qemu: Add MACVTAP support
The networking device structure now supports MACVTAP.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:43:49 +02:00
Samuel Ortiz
6d7dfa04bf qemu: Get rid of the Driver structure
By adding QemuParams() to the Device interface, we can get rid of the
driver structure and simplify further the appendDevices() routine.

With that implementation we can generate the following qemu parameters:

"-device virtio-9p-pci,fsdev=foo,mount_tag=rootfs -fsdev local,id=foo,path=/bar/foo,security-model=none"

from these single structures:

        fsdev := FSDevice{
                Driver:        Virtio9P
                FSDriver:      Local,
                ID:            "foo",
                Path:          "/bar/foo",
                MountTag:      "rootfs",
                SecurityModel: None,
        }

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:43:41 +02:00
Samuel Ortiz
cc9cb33a5d qemu: Add QMPSocket specific type
Instead of open coding the QMP socket type, we now have a specific type
for it.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
2d736d7173 qemu: Add RTC specific types
Instead of open coding the RTC fields, we now have specific types for
it.
We also have a RTC unit test now.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
e543c3383d qemu: Probe each qemu device with a driver
Having separate structures for the qemu driver definitions
and each possible device definitions is confusing and error prone as one
needs to be very careful using matching IDs and names in both
structures.

As the driver parameter can be derived from the device
ones, this patch changes the Device and Driver structures to be linked
together, i.e. each driver needs to have its corresponding device.

For example this allows us to build the following 9pfs qemu parameters:

"-fsdev local,id=foo,path=/bar/foo,security-model=none -device virtio-9p-pci,fsdev=foo,mount_tag=rootfs"

from these structures:

	fsdev := FSDevice{
		Driver:        Local,
		ID:            "foo",
		Path:          "/bar/foo",
		MountTag:      "rootfs",
		SecurityModel: None,
	}

	driver := Driver{
		Driver: Virtio9P,
		Device: fsdev,
	}

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
eda8607cc6 qemu: Add netdev options to the Device structure
With the NetDev and MACAddress strings, we can now create networking
device drivers.
We also add a unit test for netdev Device creation.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
4780e2371f qemu: Add multi-queue and vhost definitions to NetDevice
We can now specify if we want vhost to be enabled and wich fds we should
use for multiqueue support.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
137e7c7242 qemu: Add a NetDevice slice to the Config structure
The NetDevice structure represents a network device to be emulated by
qemu.
We also add the corresponding unit test.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
c0e2aacad2 qemu: Add one unit test for the Config strings
Here we test that name, UUID and the CPU model are properly built.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
5ba8ef79df qemu: Add QMP socket unit tests
We test that the QMP socket parameter is properly built.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
7b2f7eb5d8 qemu: Add Memory and SMP unit tests
We test that the memory and SMP configuration parameters are properly
built.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
2ea9b9a385 qemu: Add a Kernel unit test
We test that the kernel path and the kernel parameters are properly
built.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
8e495f6eff qemu: Add a Knobs unit test
We test that all true and all false knobs parameters are properly built.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
8aeb3d45aa qemu: Add an Object unit test
We test that memory-backend-file and empty objects parameters are
properly built.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
38e041dc9d qemu: Add Device unit tests
We add a NVDIMM, a filesystem and an empty device.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
54d32c2414 qemu: Add parameters adding unit tests
We only test the Machine parameters for now.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
ebfa382d2e qemu: Add a Knobs field to the Config structure
The Knobs structure groups all qemu isolated boolean settings.
For now this is -no-user-config, -no-defaults and -nographic.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
fe1bdcd2f7 qemu: Remove the extra parameters field from the Config structure
The extraParams is confusing and can conflict with the rest of the
Config structure definitions.
We remove it and will add new fields to that structure as needed.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
15bce61a90 qemu: Group all machine configurations into one structure
Here we group the machine type and acceleration together as they are
defined through the same qemu parameter (-machine).

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
d94b5af875 qemu: Add a VGA parameter field to the Config structure
The VGA string represents the type of VGA card qemu should emulate.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
4892d041e7 qemu: Add a Global parameter field to the Config structure
The Global string represents the set of default Device driver properties
we want qemu to use. This is mostly useful for automatically created
devices.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
612a5a9e5d qemu: Add a RTC field to the Config structure
The RTC structure represents the guest Real Time Clock configuration.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
c63ec0965a qemu: Add a SMP field to the Config structure
The SMP structure defines the amount of virtual CPUs, sockets, and
threads per CPU that is made available to the guest.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
7cf386a81c qemu: Add a Memory field to the Config structure
The Memory field holds the guest memory configuration.
It is used to define the current and maximum RAM is made available to
the guest and how this amount of RAM is splitted into several slots.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
b198bc67e7 qemu: Add a UUID field to the Config structure
The qemu UUID will be used to set the guest system UUID.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
6239e846b7 qemu: Add a Character Devices slice field to the Config structure
Qemu character devices typically allow for sending traffic from the
guest to the host by emulating a console, a tty, a serial device for
example.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
73e2d53c9a qemu: Add a Filesystem Devices slice field to the Config structure
Each Filesystem device should have a corresponding "virtio-9p-pci"
Device driver. They represent a filesystem to be exported through 9pfs.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
518ba627b1 qemu: Add a Kernel field to the Config structure
The Kernel structure holds the guest kernel configuration: its path and
its parameters. This is the kernel qemu will boot the VM from.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
b973bc59fb qemu: Add an Object slice field to the Config structure
The Object slice tells qemu which specific object to create.
Qemu objects can represent memory backend files, random number
generators, TLS credentials, etc...

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
8744dfe85e qemu: Add a Device slice field to the Config structure
We may need to support a large range of devices in the qemu created VM
and the Device slice allows us to define which drivers are needed.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
5458de70ad qemu: Add a QMP socket field to the Config structure
QMP sockets are used to send qemu specific commands to the running qemu
process.
The QMPSocket structure allows us to define the socket type we want,
along with its name.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
171182709d qemu: Add qemu's name to the Config structure
This allows us to set the qemu -name option.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Samuel Ortiz
37a1f5003d qemu: Add configuration structure to simplify LaunchQemu
LaunchQemu() now takes a Config structure that contains some more
descriptive fields than raw qemu parameter strings.

LaunchQemu is now simpler to call and more extensible as supporting more
qemu parameters would mean expanding Config instead of changing the API.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-17 00:41:13 +02:00
Mark Ryan
5ccbaf2b59 ciao-launcher, qemu: Upgrade to new context package.
Ciao will use the new standard library context package from now on.
This will allow us to use some of the new standard library functions
such as DialContext.

Partial fix for issue #541

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2016-09-12 11:51:00 +01:00
Samuel Ortiz
f57201989b qemu: Use null QMP logger when the logger parameter is nil
Or else LaunchQemu() ends up dereferencing a nil pointer and panic'ing.

Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-09-09 18:45:31 +02:00
Mark Ryan
7d4199a449 qemu: Fix ineffassign error
Fix ciao/qemu/qmp.go:349:3: ineffectual assignment to ok.

Strictly speaking this is a bug in ineffassign but it's easier
to change the ciao code.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2016-09-01 18:46:37 +01:00
Mark Ryan
7f50a41525 qemu: Fix a silly bug in LaunchQemu
There's no point in setting cmd.ExtraFiles if the fds array is an
empty slice.  This won't do any harm but is essentially a no-op.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2016-08-26 16:52:43 +01:00
Mark Ryan
fc6bf8cf80 qemu: Add package documentation
This commit adds some package documentation to the qemu package,
including an overview of the package and an example of its use.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2016-08-26 16:52:36 +01:00
Mark Ryan
306f54a907 ciao-launcher, qemu: Move launchQemu to qemu
The launcher function launchQemu has been moved to the qemu package
and is now called LaunchQemu.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2016-08-26 16:33:41 +01:00
Mark Ryan
344aa22bd2 qemu: Add the qemu package
The qemu package is a self contained package used for launching, halting
and managing qemu instances.

Signed-off-by: Mark Ryan <mark.d.ryan@intel.com>
2016-08-26 16:33:34 +01:00