]> xenbits.xensource.com Git - libvirt.git/commit
qemu: Create domain master key
authorJohn Ferlan <jferlan@redhat.com>
Tue, 29 Mar 2016 22:22:46 +0000 (18:22 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 7 Apr 2016 00:27:09 +0000 (20:27 -0400)
commitad7520e83f70892dd7ae6cd0cbc66d0759733e90
tree239ad3ff12c4aedf61e9b0d2762bb21db3a454a3
parent6af73f53c6e40e80244bdacafeb3d0525a0c4189
qemu: Create domain master key

Add a masterKey and masterKeyLen to _qemuDomainObjPrivate to store a
random domain master key and its length in order to support the ability
to encrypt/decrypt sensitive data shared between libvirt and qemu. The
key will be base64 encoded and written to a file to be used by the
command line building code to share with qemu.

New API's from this patch:

  qemuDomainGetMasterKeyFilePath:
    Return a path to where the key is located

  qemuDomainWriteMasterKeyFile: (private)
    Open (create/trunc) the masterKey path and write the masterKey

  qemuDomainMasterKeyReadFile:
    Using the master key path, open/read the file, and store the
    masterKey and masterKeyLen. Expected use only from qemuProcessReconnect

  qemuDomainGenerateRandomKey: (private)
    Generate a random key using available algorithms

    The key is generated either from the gnutls_rnd function if it
    exists or a less cryptographically strong mechanism using
    virGenerateRandomBytes

   qemuDomainMasterKeyRemove:
    Remove traces of the master key, remove the *KeyFilePath

  qemuDomainMasterKeyCreate:
    Generate the domain master key and save the key in the location
    returned by qemuDomainGetMasterKeyFilePath.

    This API will first ensure the QEMU_CAPS_OBJECT_SECRET is set
    in the capabilities. If not, then there's no need to generate
    the secret or file.

The creation of the key will be attempted from qemuProcessPrepareHost
once the libDir directory structure exists.

The removal of the key will handled from qemuProcessStop just prior
to deleting the libDir tree.

Since the key will not be written out to the domain object XML file,
the qemuProcessReconnect will read the saved file and restore the
masterKey and masterKeyLen.
src/qemu/qemu_domain.c
src/qemu/qemu_domain.h
src/qemu/qemu_process.c