tools: Fix detection of remote libvirt access in virt-qemu-sev-validate

The VM's firmware path is not extracted from the XML when invoking
virt-qemu-sev-validate in insecure mode and connecting to the local libvirt

virt-qemu-sev-validate --insecure --tk tek-tik.bin --domain test-sev-es
ERROR: Cannot access firmware path remotely

The test for remote access compares the return value from socket.gethostname()
to the return value from conn.getHostname(). The former doesn't always return
the fqdn, whereas the latter does. Use socket.getfqdn() instead.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
Jim Fehlig 2023-02-02 11:04:20 -07:00
parent 8eb54255ec
commit 0f350a4d07

View File

@ -942,7 +942,7 @@ class LibvirtConfidentialVM(ConfidentialVM):
def load_domain(self, uri, id_name_uuid, secure, ignore_config): def load_domain(self, uri, id_name_uuid, secure, ignore_config):
self.conn = libvirt.open(uri) self.conn = libvirt.open(uri)
remote = socket.gethostname() != self.conn.getHostname() remote = socket.getfqdn() != self.conn.getHostname()
if not remote and secure: if not remote and secure:
raise InsecureUsageException( raise InsecureUsageException(
"running locally on the hypervisor host is not secure") "running locally on the hypervisor host is not secure")