From nobody Sat May 11 03:32:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652428480; cv=none; d=zohomail.com; s=zohoarc; b=YU8Z83GntezdabDZGZCIVbZCkodbUFDKwZvmoIC8FrDt7OApwOlCLL9Sshq4OlElYKDO2Iv1nuNY0OciELw64VSUB5v2NAwFBaI8rtZ/Bu4zcUzPNODZCdjZXj1JHT3GCBkom46n7Tn6UMdQ8hLM9AEA8KTtZJRH+R8atWhfMUc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652428480; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZMihiPW1+RuCn7QotZeSHpBI76YOKwg1eLcX+ixbt1I=; b=J8kMYYtGi5j/vqWZlzLs0IIN1S/CfpjeX15Ws32w9mZqKF8qJfHlqJ07LP2DV+jY4F2AZujDYN32r1TGqAQHDCsm7KGbSHTRysJ1cKz3aJticpQ0JtiuKZaVKINwh/tZmyXh422Zqo50+d4FScF2AOyPd3m+KOZGqRg0sQcl/oI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1652428480646491.9800264900447; Fri, 13 May 2022 00:54:40 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-433-7bYm6hssNYiDGcexlOFgfw-1; Fri, 13 May 2022 03:54:36 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ADCCF803B22; Fri, 13 May 2022 07:54:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99E4D14A59A5; Fri, 13 May 2022 07:54:34 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1CB9C1932228; Fri, 13 May 2022 07:54:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8208D1932226 for ; Fri, 13 May 2022 07:54:31 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 633DF416362; Fri, 13 May 2022 07:54:31 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B6EC40D1CF for ; Fri, 13 May 2022 07:54:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652428479; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZMihiPW1+RuCn7QotZeSHpBI76YOKwg1eLcX+ixbt1I=; b=fPWZAePFxOWJDf4CkOFm3uOxRYA8mDCSdelYRm+fi8PUkX9FIGRECFg++XwKFk05LUxVE9 9W8fcq5JKgfDaREXY27DCGvdOi1pCrU03JX/sprx9HU4ZieN3bTjyGCAil3bjS3XlSojRH Fqkyouq5SjHfqOcf4TuwwvzKYCpPGOQ= X-MC-Unique: 7bYm6hssNYiDGcexlOFgfw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 1/3] qemu: Separate out save code from qemuDomainManagedSave() Date: Fri, 13 May 2022 09:54:26 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652428482112100001 Content-Type: text/plain; charset="utf-8"; x-default="true" The code that actually does managed save within qemuDomainManagedSave() is going to be reused shortly. Move it out into a separate helper. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/qemu/qemu_driver.c | 82 ++++++++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 34 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 4b690a520b..7d8c7176d9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2760,6 +2760,53 @@ qemuDomainSaveInternal(virQEMUDriver *driver, } =20 =20 +static char * +qemuDomainManagedSavePath(virQEMUDriver *driver, virDomainObj *vm) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); + + return g_strdup_printf("%s/%s.save", cfg->saveDir, vm->def->name); +} + + +static int +qemuDomainManagedSaveHelper(virQEMUDriver *driver, + virDomainObj *vm, + unsigned int flags) +{ + g_autoptr(virQEMUDriverConfig) cfg =3D NULL; + g_autoptr(virCommand) compressor =3D NULL; + g_autofree char *path =3D NULL; + int compressed; + + if (virDomainObjCheckActive(vm) < 0) + return -1; + + if (!vm->persistent) { + virReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot do managed save for transient domain")); + return -1; + } + + cfg =3D virQEMUDriverGetConfig(driver); + if ((compressed =3D qemuSaveImageGetCompressionProgram(cfg->saveImageF= ormat, + &compressor, + "save", false)) <= 0) + return -1; + + path =3D qemuDomainManagedSavePath(driver, vm); + + VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, path); + + if (qemuDomainSaveInternal(driver, vm, path, compressed, + compressor, NULL, flags) < 0) + return -1; + + vm->hasManagedSave =3D true; + return 0; +} + + static int qemuDomainSaveFlags(virDomainPtr dom, const char *path, const char *dxml, unsigned int flags) @@ -2860,23 +2907,12 @@ qemuDomainSaveParams(virDomainPtr dom, return ret; } =20 -static char * -qemuDomainManagedSavePath(virQEMUDriver *driver, virDomainObj *vm) -{ - g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - - return g_strdup_printf("%s/%s.save", cfg->saveDir, vm->def->name); -} =20 static int qemuDomainManagedSave(virDomainPtr dom, unsigned int flags) { virQEMUDriver *driver =3D dom->conn->privateData; - g_autoptr(virQEMUDriverConfig) cfg =3D NULL; - int compressed; - g_autoptr(virCommand) compressor =3D NULL; virDomainObj *vm; - g_autofree char *name =3D NULL; int ret =3D -1; =20 virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE | @@ -2889,29 +2925,7 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int= flags) if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - if (virDomainObjCheckActive(vm) < 0) - goto cleanup; - - if (!vm->persistent) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot do managed save for transient domain")); - goto cleanup; - } - - cfg =3D virQEMUDriverGetConfig(driver); - if ((compressed =3D qemuSaveImageGetCompressionProgram(cfg->saveImageF= ormat, - &compressor, - "save", false)) <= 0) - goto cleanup; - - name =3D qemuDomainManagedSavePath(driver, vm); - - VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, name); - - ret =3D qemuDomainSaveInternal(driver, vm, name, compressed, - compressor, NULL, flags); - if (ret =3D=3D 0) - vm->hasManagedSave =3D true; + ret =3D qemuDomainManagedSaveHelper(driver, vm, flags); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.35.1 From nobody Sat May 11 03:32:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652428487; cv=none; d=zohomail.com; s=zohoarc; b=Xot33TIMIu1lRn/89811dU2E+xVcupy0Ot8fH4LOXy4uGk9mtlyBOFN/oemwPC7XllvMPKifQJc5FrUOGzqy5VXjpnSKGOCCkKNfucIpk34+e0qjprVTC4qJOS6nnATWSYK1dUeY8u8CLRqyJLrax1q6F9yqndhbOgmlO8ExYK4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652428487; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZG8j3vlMKHXoSSw9uGcjS+ojqmTh9WiJXxKz1pjQPi0=; b=c68qMY29kRDOSG/TsW2hJGs/z6NPGDVIHOArIf8zSGNJ7uDlDn4lq54X8NkwrFb/DqWV1MvZ08Bx1a/LffbvxLUzAU6yRZLQzTs52XVrCiorrMkxcEl9a8A31crCiM+igGsQ5fuIcHkaHi7SVixDHtU4lOLWBcooY7fLJWZFRpw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652428487161925.4548375731073; Fri, 13 May 2022 00:54:47 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-272-OR5dTDwjM2afN-Tr7A3ukw-1; Fri, 13 May 2022 03:54:42 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A980219705B7; Fri, 13 May 2022 07:54:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 966B914C1D40; Fri, 13 May 2022 07:54:40 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E7AE3193222E; Fri, 13 May 2022 07:54:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 369B91932226 for ; Fri, 13 May 2022 07:54:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 006D2401E89; Fri, 13 May 2022 07:54:32 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D44B40D1CF for ; Fri, 13 May 2022 07:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652428486; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ZG8j3vlMKHXoSSw9uGcjS+ojqmTh9WiJXxKz1pjQPi0=; b=ILUc9mQUixKGZEAQEUn0rnvOtKAj57mha8ruxxignsgTNoUaDG2RWDLajhdmJRdeipC27b hxAtq+ZIQl1AqxJDQBYGZ2mRqoVOk5IKuPTYkHmuL9Tqc7ud/ISVK3px7lbVSjqZTe9u4C dk9rXffqyKG1Rohf5uglsAWFw9chqIg= X-MC-Unique: OR5dTDwjM2afN-Tr7A3ukw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 2/3] lib: Repurpose virDomainSaveParams() with no VIR_DOMAIN_SAVE_PARAM_FILE Date: Fri, 13 May 2022 09:54:27 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652428488116100003 Content-Type: text/plain; charset="utf-8"; x-default="true" When no VIR_DOMAIN_SAVE_PARAM_FILE typed param is set when calling virDomainSaveParams() then in turn virQEMUFileOpenAs() tries to open a NULL path. We have two options now: 1) require the typed param, which in turn may be promoted to a regular argument, or 2) use this opportunity to make the API behave like virDomainManagedSave() and use typed params to pass extra arguments, instead of having to invent new managed save API with typed params. Let's go with option 2, as it is more future proof. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/libvirt-domain.c | 2 ++ src/qemu/qemu_driver.c | 33 ++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index d1d62daa71..208c2438fe 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -1007,6 +1007,8 @@ virDomainSaveFlags(virDomainPtr domain, const char *t= o, * @flags: bitwise-OR of virDomainSaveRestoreFlags * * This method extends virDomainSaveFlags by adding parameters. + * If VIR_DOMAIN_SAVE_PARAM_FILE is not provided then a managed save is + * performed (see virDomainManagedSave). * * Returns 0 in case of success and -1 in case of failure. * diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7d8c7176d9..0b31c73bb9 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -2772,6 +2772,7 @@ qemuDomainManagedSavePath(virQEMUDriver *driver, virD= omainObj *vm) static int qemuDomainManagedSaveHelper(virQEMUDriver *driver, virDomainObj *vm, + const char *dxml, unsigned int flags) { g_autoptr(virQEMUDriverConfig) cfg =3D NULL; @@ -2799,7 +2800,7 @@ qemuDomainManagedSaveHelper(virQEMUDriver *driver, VIR_INFO("Saving state of domain '%s' to '%s'", vm->def->name, path); =20 if (qemuDomainSaveInternal(driver, vm, path, compressed, - compressor, NULL, flags) < 0) + compressor, dxml, flags) < 0) return -1; =20 vm->hasManagedSave =3D true; @@ -2853,17 +2854,18 @@ qemuDomainSave(virDomainPtr dom, const char *path) =20 static int qemuDomainSaveParams(virDomainPtr dom, - virTypedParameterPtr params, int nparams, + virTypedParameterPtr params, + int nparams, unsigned int flags) { + virQEMUDriver *driver =3D dom->conn->privateData; + g_autoptr(virQEMUDriverConfig) cfg =3D NULL; + virDomainObj *vm =3D NULL; + g_autoptr(virCommand) compressor =3D NULL; const char *to =3D NULL; const char *dxml =3D NULL; - virQEMUDriver *driver =3D dom->conn->privateData; int compressed; - g_autoptr(virCommand) compressor =3D NULL; int ret =3D -1; - virDomainObj *vm =3D NULL; - g_autoptr(virQEMUDriverConfig) cfg =3D NULL; =20 virCheckFlags(VIR_DOMAIN_SAVE_BYPASS_CACHE | VIR_DOMAIN_SAVE_RUNNING | @@ -2884,18 +2886,23 @@ qemuDomainSaveParams(virDomainPtr dom, VIR_DOMAIN_SAVE_PARAM_DXML, &dxml) < 0) return -1; =20 - cfg =3D virQEMUDriverGetConfig(driver); - if ((compressed =3D qemuSaveImageGetCompressionProgram(cfg->saveImageF= ormat, - &compressor, - "save", false)) <= 0) - goto cleanup; - if (!(vm =3D qemuDomainObjFromDomain(dom))) goto cleanup; =20 if (virDomainSaveParamsEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 + if (!to) { + /* If no save path was provided then this behaves as managed save.= */ + return qemuDomainManagedSaveHelper(driver, vm, dxml, flags); + } + + cfg =3D virQEMUDriverGetConfig(driver); + if ((compressed =3D qemuSaveImageGetCompressionProgram(cfg->saveImageF= ormat, + &compressor, + "save", false)) <= 0) + goto cleanup; + if (virDomainObjCheckActive(vm) < 0) goto cleanup; =20 @@ -2925,7 +2932,7 @@ qemuDomainManagedSave(virDomainPtr dom, unsigned int = flags) if (virDomainManagedSaveEnsureACL(dom->conn, vm->def) < 0) goto cleanup; =20 - ret =3D qemuDomainManagedSaveHelper(driver, vm, flags); + ret =3D qemuDomainManagedSaveHelper(driver, vm, NULL, flags); =20 cleanup: virDomainObjEndAPI(&vm); --=20 2.35.1 From nobody Sat May 11 03:32:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652428495; cv=none; d=zohomail.com; s=zohoarc; b=OKIxf8NcjyH9faeVdS2dduXew5XwemhXY7OpvjBtcNNGNoXM0azbJxGKRpTzLFOE/rryly6OhvDHmbxBVeTi9EkrFaw73oQDDLkk19C5Xpu7okB7HevuyHQzTwhkQ9SxOgE3fSQEl1MKVyBa8KP2kmNO1UJVR8iSZsguHH899XM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652428495; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aTo1V35hpz+FvKy+MURdzVOZgf6AR0lirvrLs/FMN1U=; b=QP3oKUDMBHcw7gIVe5gyFCjH9DNpGYJrDoeaAvUXD1SGys8Nb/MvABc/OJNmJMJhRuieyjUgVwQXFLtbgnhNarrA7xmiLjqw18Gfl+JctX9eWqU3o/sYKN95h4PSwPvq42i4wVT6o9VdqEUDnEvC6KmFo77OzMGS2lg9hQy3fIM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1652428494963468.52485852285747; Fri, 13 May 2022 00:54:54 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-594-tDPIkZH-Pi6edKuufQ0k-Q-1; Fri, 13 May 2022 03:54:48 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B368E38332A4; Fri, 13 May 2022 07:54:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9695E4154C1; Fri, 13 May 2022 07:54:46 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 71655193211F; Fri, 13 May 2022 07:54:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AD4901932226 for ; Fri, 13 May 2022 07:54:32 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 939B7416361; Fri, 13 May 2022 07:54:32 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C0F240D1CF for ; Fri, 13 May 2022 07:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652428494; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aTo1V35hpz+FvKy+MURdzVOZgf6AR0lirvrLs/FMN1U=; b=MhURKzVO/jubiEOCkoscSic34AEGKplbio3UbCb/rmHamIgEijfB09UiL2oV0z2x8/Qf+2 8rK/EA7ZSLxRG7xIE3ZoaEPTOcXtK5/wzucR/BTSK7xVm5OLlaj/0zT9fwZbDBv08z7uv3 eXgylBM2jgB6iQUpwn+E6yfDu6Enh/A= X-MC-Unique: tDPIkZH-Pi6edKuufQ0k-Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 3/3] virDomainRestoreFlags: Require VIR_DOMAIN_SAVE_PARAM_FILE for now Date: Fri, 13 May 2022 09:54:28 +0200 Message-Id: <942a361df0577a080bc4ba4f5bb291302f7c4d4f.1652428318.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652428496152100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Calling virDomainRestoreFlags() with no typed params results in an error in open() because it tries to open a NULL path. Obviously, this is wrong and path to restore from must be provided, at least for now until other sources of restore are introduced. Then this limitation can be relaxed. Signed-off-by: Michal Privoznik Reviewed-by: Martin Kletzander --- src/libvirt-domain.c | 4 +++- src/qemu/qemu_driver.c | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 208c2438fe..a32630a6e9 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -1190,7 +1190,9 @@ virDomainRestoreFlags(virConnectPtr conn, const char = *from, const char *dxml, * @nparams: number of restore parameters * @flags: bitwise-OR of virDomainSaveRestoreFlags * - * This method extends virDomainRestoreFlags by adding parameters. + * This method extends virDomainRestoreFlags by adding parameters. For + * now, VIR_DOMAIN_SAVE_PARAM_FILE is required but this requirement may + * be lifted in the future. * * Returns 0 in case of success and -1 in case of failure. * diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0b31c73bb9..702fd0239c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -5967,6 +5967,12 @@ qemuDomainRestoreParams(virConnectPtr conn, VIR_DOMAIN_SAVE_PARAM_DXML, &dxml) < 0) return -1; =20 + if (!path) { + virReportError(VIR_ERR_INVALID_ARG, "%s", + _("missing path to restore from")); + return -1; + } + ret =3D qemuDomainRestoreInternal(conn, path, dxml, flags, virDomainRestoreParamsEnsureACL); return ret; --=20 2.35.1