File 0f350a4d-virt-qemu-sev-validate-remote-detect.patch of Package libvirt.29326

From 2be1087336fe10991563d4a2be5b2c1bf8e1b004 Mon Sep 17 00:00:00 2001
From: Jim Fehlig <jfehlig@suse.com>
Date: Thu, 2 Feb 2023 11:04:20 -0700
Subject: [PATCH] tools: Fix detection of remote libvirt access in
 virt-qemu-sev-validate
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

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>
(cherry picked from commit 0f350a4d070e952b0ecc7631708478ddfd43ba3f)
---
 tools/virt-qemu-sev-validate | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: libvirt-9.0.0/tools/virt-qemu-sev-validate
===================================================================
--- libvirt-9.0.0.orig/tools/virt-qemu-sev-validate
+++ libvirt-9.0.0/tools/virt-qemu-sev-validate
@@ -942,7 +942,7 @@ class LibvirtConfidentialVM(Confidential
     def load_domain(self, uri, id_name_uuid, secure, ignore_config):
         self.conn = libvirt.open(uri)
 
-        remote = socket.gethostname() != self.conn.getHostname()
+        remote = socket.getfqdn() != self.conn.getHostname()
         if not remote and secure:
             raise InsecureUsageException(
                 "running locally on the hypervisor host is not secure")
openSUSE Build Service is sponsored by