qemu_shim: Always pre-create root dir
qemu_shim: Always pre-create root dir

This problem is reproducible only with secret driver. When
starting a domain via virt-qemu-run and both secret and
(nonexistent) root directory specified this is what happens:

1) virt-qemu-run opens "secret:///embed?root=$rootdir"
   connection, which results in the secret driver initialization
   (done in secretStateInitialize()). During this process, the
   driver creates its own configDir (derived from $rootdir)
   including those parents which don't exists yet. This is all
   done with the mode S_IRWXU and thus results in the $rootdir
   being created with very restrictive mode (specifically, +x is
   missing for group and others).

2) now, virt-qemu-run opens "qemu:///embed?root=$rootdir" and
   calls virDomainCreateXML(). This results in the master-key.aes
   being written somewhere under the $rootdir and telling qemu
   where to find it.

But because the secret driver created $rootdir with too
restrictive mode, qemu can't access the file (even though it
knows the full path) and fails to start.

It looks like the best solution is to pre-create the root
directory before opening any connection (letting any driver
initialize itself) and set its mode to something less
restrictive.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1859873
Signed-off-by: Michal Privoznik <83d82aaba2eed257f4814b0c239c260c4caaadf0@redhat.com>
Reviewed-by: Andrea Bolognani <3ada0bee826c753786fdbba72243dfba997094cf@redhat.com>

nertpinx/libvirt,libvirt/libvirt,libvirt/libvirt,olafhering/libvirt,jfehlig/libvirt,zippy2/libvirt,crobinso/libvirt,olafhering/libvirt,libvirt/libvirt,zippy2/libvirt,olafhering/libvirt,crobinso/libvirt,jfehlig/libvirt,libvirt/libvirt,nertpinx/libvirt,crobinso/libvirt,crobinso/libvirt,olafhering/libvirt,zippy2/libvirt,nertpinx/libvirt,nertpinx/libvirt,nertpinx/libvirt,zippy2/libvirt,jfehlig/libvirt,jfehlig/libvirt