From nobody Sat Nov 23 17:44:06 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1724084562829693.8709384990804; Mon, 19 Aug 2024 09:22:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9437211B4; Mon, 19 Aug 2024 12:22:41 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id ECB211631; Mon, 19 Aug 2024 12:20:11 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 406681660; Mon, 19 Aug 2024 12:20:08 -0400 (EDT) Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 1FB24159C for ; Mon, 19 Aug 2024 12:19:56 -0400 (EDT) Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-5bede548f7cso2556597a12.2 for ; Mon, 19 Aug 2024 09:19:56 -0700 (PDT) Received: from localhost.localdomain ([37.186.51.21]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5bebbde4964sm5738298a12.24.2024.08.19.09.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 09:19:53 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724084395; x=1724689195; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5Ekr0NDBQTYSqRhFKCC1dyNasOjQzpJnRG9JR9puUYc=; b=YraFJu8t9euFgEai+FNZDVvNQ9BF8TmAniAD5+yQIFts408ZlYk5Zms3vyHki9E5DB NXJLgRs2OxXX8uRPfc1nlq5gQz6fYCU9bk7ptLaL5yb+8qO40YETHH2t5TMnpmQBkDje INX091nlfGvSQs4ZAfSuT8k3Pvig3OSPhp0caEgdiDUvt3Xsd8B/e+5JUYVs424BlaLV 6mv9KtJ92dyqIdvg/+elIdmCO/WiAww35zDIFYlC6ah1yOTRD2/BXgY4bci98+Ap5jdL f6+kMqoFSzFCBQNSvJgFHE+t9119WXoZnVQrkiLL+rTO+D9K3YawsV5idi41zDMomsdy FjmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724084395; x=1724689195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5Ekr0NDBQTYSqRhFKCC1dyNasOjQzpJnRG9JR9puUYc=; b=JDD3wQHgiq8DKS7j/mRykeQJMmzNPEQGVZY5mlWutc/C1AOkuWPK1/jUoYH7HJy1q0 Vg3gnD6L/4NKBWIyM/YkUUZdRhOXJsoqTArSR5vrggfZIuz4ZfVCCraCfgw3JlQlduJM kBw9KuJvS2MRI2CSy07iReRggD/Hiwa4XX32oadRyOeHlAfI/ZPYWP9BCm1QfVmmOFne /WeTXBthdXDAJJQLqmWDTcvHMhX3F+aZ6jcLHC8e0LleR+McOUf39qFjKx3WZX1Nu8om ZQY9Us+9pjTO9OFpIxFpx3Tfi9vKsw/pmJOqWi0VIsCARueGfwiU60pt8lA8mp5MVnUl t+4g== X-Gm-Message-State: AOJu0YycWOrRgQzN0Z6ah42ijizl61tjHMNaDvMezuVpZ2AwOv4Lp+2+ Ua/+ri9slzJ9I0egHdxm8mDp73SXkcaoNhDU+UpPhuZJ5UDfAEU85PENng== X-Google-Smtp-Source: AGHT+IEXgTbKeAeqeaKdQ5a2fu3lcN+P/0XQKIuPmQH5CkB7FnLydUp9IIhxkkjnHsHeCp+K527aBg== X-Received: by 2002:a05:6402:84f:b0:5bb:9b22:68f4 with SMTP id 4fb4d7f45d1cf-5beca59a339mr7483167a12.18.1724084394513; Mon, 19 Aug 2024 09:19:54 -0700 (PDT) From: Rayhan Faizel To: devel@lists.libvirt.org Subject: [PATCH 03/14] tests: Export handlers for fake secondary drivers Date: Mon, 19 Aug 2024 21:39:41 +0530 Message-Id: <20240819160952.351383-4-rayhan.faizel@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819160952.351383-1-rayhan.faizel@gmail.com> References: <20240819160952.351383-1-rayhan.faizel@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4IYTR7NLC6TOPP7UHVC4I4G3WERNQEHQ X-Message-ID-Hash: 4IYTR7NLC6TOPP7UHVC4I4G3WERNQEHQ X-MailFrom: rayhan.faizel@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Rayhan Faizel X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1724084563870116600 Content-Type: text/plain; charset="utf-8" This patch exports handlers for fake network, storage and secret drivers which will be used by the QEMU XML domain fuzzer. Signed-off-by: Rayhan Faizel --- tests/qemuxmlconftest.c | 249 -------------------------------------- tests/testutilsqemu.c | 256 ++++++++++++++++++++++++++++++++++++++++ tests/testutilsqemu.h | 57 +++++++++ 3 files changed, 313 insertions(+), 249 deletions(-) diff --git a/tests/qemuxmlconftest.c b/tests/qemuxmlconftest.c index 89292af300..35830257c7 100644 --- a/tests/qemuxmlconftest.c +++ b/tests/qemuxmlconftest.c @@ -33,52 +33,6 @@ =20 static virQEMUDriver driver; =20 -static unsigned char * -fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED, - size_t *value_size, - unsigned int fakeflags G_GNUC_UNUSED) -{ - char *secret; - secret =3D g_strdup("AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A"); - *value_size =3D strlen(secret); - return (unsigned char *) secret; -} - -static virSecretPtr -fakeSecretLookupByUsage(virConnectPtr conn, - int usageType, - const char *usageID) -{ - unsigned char uuid[VIR_UUID_BUFLEN]; - if (usageType =3D=3D VIR_SECRET_USAGE_TYPE_VOLUME) { - if (!STRPREFIX(usageID, "/storage/guest_disks/")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "test provided invalid volume storage prefix '%= s'", - usageID); - return NULL; - } - } else if (STRNEQ(usageID, "mycluster_myname") && - STRNEQ(usageID, "client.admin secret")) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "test provided incorrect usage '%s'", usageID); - return NULL; - } - - if (virUUIDGenerate(uuid) < 0) - return NULL; - - return virGetSecret(conn, uuid, usageType, usageID); -} - -static virSecretPtr -fakeSecretLookupByUUID(virConnectPtr conn, - const unsigned char *uuid) -{ - /* NB: This mocked value could be "tls" or "volume" depending on - * which test is being run, we'll leave at NONE (or 0) */ - return virGetSecret(conn, uuid, VIR_SECRET_USAGE_TYPE_NONE, ""); -} - static virSecretDriver fakeSecretDriver =3D { .connectNumOfSecrets =3D NULL, .connectListSecrets =3D NULL, @@ -92,118 +46,6 @@ static virSecretDriver fakeSecretDriver =3D { }; =20 =20 -# define STORAGE_POOL_XML_PATH "storagepoolxml2xmlout/" -static const unsigned char fakeUUID[VIR_UUID_BUFLEN] =3D "fakeuuid"; - -static virStoragePoolPtr -fakeStoragePoolLookupByName(virConnectPtr conn, - const char *name) -{ - g_autofree char *xmlpath =3D NULL; - - if (STRNEQ(name, "inactive")) { - xmlpath =3D g_strdup_printf("%s/%s%s.xml", abs_srcdir, - STORAGE_POOL_XML_PATH, name); - - if (!virFileExists(xmlpath)) { - virReportError(VIR_ERR_NO_STORAGE_POOL, - "File '%s' not found", xmlpath); - return NULL; - } - } - - return virGetStoragePool(conn, name, fakeUUID, NULL, NULL); -} - - -static virStorageVolPtr -fakeStorageVolLookupByName(virStoragePoolPtr pool, - const char *name) -{ - g_auto(GStrv) volinfo =3D NULL; - - if (STREQ(pool->name, "inactive")) { - virReportError(VIR_ERR_OPERATION_INVALID, - "storage pool '%s' is not active", pool->name); - return NULL; - } - - if (STREQ(name, "nonexistent")) { - virReportError(VIR_ERR_NO_STORAGE_VOL, - "no storage vol with matching name '%s'", name); - return NULL; - } - - if (!(volinfo =3D g_strsplit(name, "+", 2))) - return NULL; - - if (!volinfo[1]) { - return virGetStorageVol(pool->conn, pool->name, name, "block", NUL= L, NULL); - } - - return virGetStorageVol(pool->conn, pool->name, volinfo[1], volinfo[0], - NULL, NULL); -} - -static int -fakeStorageVolGetInfo(virStorageVolPtr vol, - virStorageVolInfoPtr info) -{ - memset(info, 0, sizeof(*info)); - - info->type =3D virStorageVolTypeFromString(vol->key); - - if (info->type < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "Invalid volume type '%s'", vol->key); - return -1; - } - - return 0; -} - - -static char * -fakeStorageVolGetPath(virStorageVolPtr vol) -{ - return g_strdup_printf("/some/%s/device/%s", vol->key, vol->name); -} - - -static char * -fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool, - unsigned int flags_unused G_GNUC_UNUSED) -{ - g_autofree char *xmlpath =3D NULL; - char *xmlbuf =3D NULL; - - if (STREQ(pool->name, "inactive")) { - virReportError(VIR_ERR_NO_STORAGE_POOL, NULL); - return NULL; - } - - xmlpath =3D g_strdup_printf("%s/%s%s.xml", abs_srcdir, STORAGE_POOL_XM= L_PATH, - pool->name); - - if (virTestLoadFile(xmlpath, &xmlbuf) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "failed to load XML file '%s'", - xmlpath); - return NULL; - } - - return xmlbuf; -} - -static int -fakeStoragePoolIsActive(virStoragePoolPtr pool) -{ - if (STREQ(pool->name, "inactive")) - return 0; - - return 1; -} - /* Test storage pool implementation * * These functions aid testing of storage pool related stuff when creating= a @@ -257,97 +99,6 @@ static virNWFilterDriver fakeNWFilterDriver =3D { }; =20 =20 -/* name of the fake network shall be constructed as: - * NETWORKXMLNAME;NETWORKPORTXMLNAME - * where: - * NETWORKXMLNAME resolves to abs_srcdir/networkxml2xmlin/NETWORKXMLNAME.= xml - * NETWORKPORTXMLNAME resolves to abs_srcdir/virnetworkportxml2xmldata/NE= TWORKPORTXMLNAME.xml - */ -static virNetworkPtr -fakeNetworkLookupByName(virConnectPtr conn, - const char *name) -{ - unsigned char uuid[VIR_UUID_BUFLEN]; - g_autofree char *netname =3D g_strdup(name); - g_autofree char *path =3D NULL; - char *tmp; - - memset(uuid, 0, VIR_UUID_BUFLEN); - - if ((tmp =3D strchr(netname, ';'))) { - *tmp =3D '\0'; - } else { - virReportError(VIR_ERR_NO_NETWORK, - "Malformed fake network name '%s'. See fakeNetworkL= ookupByName.", - name); - return NULL; - } - - path =3D g_strdup_printf(abs_srcdir "/networkxml2xmlin/%s.xml", netnam= e); - - if (!virFileExists(path)) { - virReportError(VIR_ERR_NO_NETWORK, "fake network '%s' not found", = path); - return NULL; - } - - return virGetNetwork(conn, name, uuid); -} - - -static char * -fakeNetworkGetXMLDesc(virNetworkPtr network, - unsigned int noflags G_GNUC_UNUSED) -{ - g_autofree char *netname =3D g_strdup(network->name); - g_autofree char *path =3D NULL; - char *xml =3D NULL; - - *(strchr(netname, ';')) =3D '\0'; - - path =3D g_strdup_printf(abs_srcdir "/networkxml2xmlin/%s.xml", netnam= e); - - if (virFileReadAll(path, 4 * 1024, &xml) < 0) - return NULL; - - return xml; -} - - -static virNetworkPortPtr -fakeNetworkPortCreateXML(virNetworkPtr net, - const char *xmldesc G_GNUC_UNUSED, - unsigned int noflags G_GNUC_UNUSED) -{ - unsigned char uuid[VIR_UUID_BUFLEN]; - g_autofree char *portname =3D g_strdup(strchr(net->name, ';') + 1); - g_autofree char *path =3D g_strdup_printf(abs_srcdir "/virnetworkportx= ml2xmldata/%s.xml", portname); - - memset(uuid, 0, VIR_UUID_BUFLEN); - - if (!virFileExists(path)) { - virReportError(VIR_ERR_NO_NETWORK_PORT, "fake network port '%s' no= t found", path); - return NULL; - } - - return virGetNetworkPort(net, uuid); -} - - -static char * -fakeNetworkPortGetXMLDesc(virNetworkPortPtr port, - unsigned int noflags G_GNUC_UNUSED) -{ - g_autofree char *portname =3D g_strdup(strchr(port->net->name, ';') + = 1); - g_autofree char *path =3D g_strdup_printf(abs_srcdir "/virnetworkportx= ml2xmldata/%s.xml", portname); - char *xml =3D NULL; - - if (virFileReadAll(path, 4 * 1024, &xml) < 0) - return NULL; - - return xml; -} - - static virNetworkDriver fakeNetworkDriver =3D { .networkLookupByName =3D fakeNetworkLookupByName, .networkGetXMLDesc =3D fakeNetworkGetXMLDesc, diff --git a/tests/testutilsqemu.c b/tests/testutilsqemu.c index ee6cae218a..4445fafd23 100644 --- a/tests/testutilsqemu.c +++ b/tests/testutilsqemu.c @@ -13,6 +13,7 @@ # include "virstring.h" # include "virfilecache.h" # include "virtpm.h" +# include "conf/storage_conf.h" =20 # include # include @@ -1076,3 +1077,258 @@ testQemuPrepareHostBackendChardevOne(virDomainDevic= eDef *dev, =20 return 0; } + + +# define STORAGE_POOL_XML_PATH "storagepoolxml2xmlout/" +static const unsigned char fakeUUID[VIR_UUID_BUFLEN] =3D "fakeuuid"; + +virStoragePoolPtr +fakeStoragePoolLookupByName(virConnectPtr conn, + const char *name) +{ + g_autofree char *xmlpath =3D NULL; + + if (STRNEQ(name, "inactive")) { + xmlpath =3D g_strdup_printf("%s/%s%s.xml", abs_srcdir, + STORAGE_POOL_XML_PATH, name); + + if (!virFileExists(xmlpath)) { + virReportError(VIR_ERR_NO_STORAGE_POOL, + "File '%s' not found", xmlpath); + return NULL; + } + } + + return virGetStoragePool(conn, name, fakeUUID, NULL, NULL); +} + + +virStorageVolPtr +fakeStorageVolLookupByName(virStoragePoolPtr pool, + const char *name) +{ + g_auto(GStrv) volinfo =3D NULL; + + if (STREQ(pool->name, "inactive")) { + virReportError(VIR_ERR_OPERATION_INVALID, + "storage pool '%s' is not active", pool->name); + return NULL; + } + + if (STREQ(name, "nonexistent")) { + virReportError(VIR_ERR_NO_STORAGE_VOL, + "no storage vol with matching name '%s'", name); + return NULL; + } + + if (!(volinfo =3D g_strsplit(name, "+", 2))) + return NULL; + + if (!volinfo[1]) { + return virGetStorageVol(pool->conn, pool->name, name, "block", NUL= L, NULL); + } + + return virGetStorageVol(pool->conn, pool->name, volinfo[1], volinfo[0], + NULL, NULL); +} + + +int +fakeStorageVolGetInfo(virStorageVolPtr vol, + virStorageVolInfoPtr info) +{ + memset(info, 0, sizeof(*info)); + + info->type =3D virStorageVolTypeFromString(vol->key); + + if (info->type < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "Invalid volume type '%s'", vol->key); + return -1; + } + + return 0; +} + + +char * +fakeStorageVolGetPath(virStorageVolPtr vol) +{ + return g_strdup_printf("/some/%s/device/%s", vol->key, vol->name); +} + + +char * +fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool, + unsigned int flags_unused G_GNUC_UNUSED) +{ + g_autofree char *xmlpath =3D NULL; + char *xmlbuf =3D NULL; + + if (STREQ(pool->name, "inactive")) { + virReportError(VIR_ERR_NO_STORAGE_POOL, NULL); + return NULL; + } + + xmlpath =3D g_strdup_printf("%s/%s%s.xml", abs_srcdir, STORAGE_POOL_XM= L_PATH, + pool->name); + + if (virTestLoadFile(xmlpath, &xmlbuf) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "failed to load XML file '%s'", + xmlpath); + return NULL; + } + + return xmlbuf; +} + + +int +fakeStoragePoolIsActive(virStoragePoolPtr pool) +{ + if (STREQ(pool->name, "inactive")) + return 0; + + return 1; +} + + +/* name of the fake network shall be constructed as: + * NETWORKXMLNAME;NETWORKPORTXMLNAME + * where: + * NETWORKXMLNAME resolves to abs_srcdir/networkxml2xmlin/NETWORKXMLNAME.= xml + * NETWORKPORTXMLNAME resolves to abs_srcdir/virnetworkportxml2xmldata/NE= TWORKPORTXMLNAME.xml + */ +virNetworkPtr +fakeNetworkLookupByName(virConnectPtr conn, + const char *name) +{ + unsigned char uuid[VIR_UUID_BUFLEN]; + g_autofree char *netname =3D g_strdup(name); + g_autofree char *path =3D NULL; + char *tmp; + + memset(uuid, 0, VIR_UUID_BUFLEN); + + if ((tmp =3D strchr(netname, ';'))) { + *tmp =3D '\0'; + } else { + virReportError(VIR_ERR_NO_NETWORK, + "Malformed fake network name '%s'. See fakeNetworkL= ookupByName.", + name); + return NULL; + } + + path =3D g_strdup_printf(abs_srcdir "/networkxml2xmlin/%s.xml", netnam= e); + + if (!virFileExists(path)) { + virReportError(VIR_ERR_NO_NETWORK, "fake network '%s' not found", = path); + return NULL; + } + + return virGetNetwork(conn, name, uuid); +} + + +char * +fakeNetworkGetXMLDesc(virNetworkPtr network, + unsigned int noflags G_GNUC_UNUSED) +{ + g_autofree char *netname =3D g_strdup(network->name); + g_autofree char *path =3D NULL; + char *xml =3D NULL; + + *(strchr(netname, ';')) =3D '\0'; + + path =3D g_strdup_printf(abs_srcdir "/networkxml2xmlin/%s.xml", netnam= e); + + if (virFileReadAll(path, 4 * 1024, &xml) < 0) + return NULL; + + return xml; +} + + +virNetworkPortPtr +fakeNetworkPortCreateXML(virNetworkPtr net, + const char *xmldesc G_GNUC_UNUSED, + unsigned int noflags G_GNUC_UNUSED) +{ + unsigned char uuid[VIR_UUID_BUFLEN]; + g_autofree char *portname =3D g_strdup(strchr(net->name, ';') + 1); + g_autofree char *path =3D g_strdup_printf(abs_srcdir "/virnetworkportx= ml2xmldata/%s.xml", portname); + + memset(uuid, 0, VIR_UUID_BUFLEN); + + if (!virFileExists(path)) { + virReportError(VIR_ERR_NO_NETWORK_PORT, "fake network port '%s' no= t found", path); + return NULL; + } + + return virGetNetworkPort(net, uuid); +} + + +char * +fakeNetworkPortGetXMLDesc(virNetworkPortPtr port, + unsigned int noflags G_GNUC_UNUSED) +{ + g_autofree char *portname =3D g_strdup(strchr(port->net->name, ';') + = 1); + g_autofree char *path =3D g_strdup_printf(abs_srcdir "/virnetworkportx= ml2xmldata/%s.xml", portname); + char *xml =3D NULL; + + if (virFileReadAll(path, 4 * 1024, &xml) < 0) + return NULL; + + return xml; +} + + +unsigned char * +fakeSecretGetValue(virSecretPtr obj G_GNUC_UNUSED, + size_t *value_size, + unsigned int fakeflags G_GNUC_UNUSED) +{ + char *secret; + secret =3D g_strdup("AQCVn5hO6HzFAhAAq0NCv8jtJcIcE+HOBlMQ1A"); + *value_size =3D strlen(secret); + return (unsigned char *) secret; +} + + +virSecretPtr +fakeSecretLookupByUsage(virConnectPtr conn, + int usageType, + const char *usageID) +{ + unsigned char uuid[VIR_UUID_BUFLEN]; + if (usageType =3D=3D VIR_SECRET_USAGE_TYPE_VOLUME) { + if (!STRPREFIX(usageID, "/storage/guest_disks/")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "test provided invalid volume storage prefix '%= s'", + usageID); + return NULL; + } + } else if (STRNEQ(usageID, "mycluster_myname") && + STRNEQ(usageID, "client.admin secret")) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "test provided incorrect usage '%s'", usageID); + return NULL; + } + + if (virUUIDGenerate(uuid) < 0) + return NULL; + + return virGetSecret(conn, uuid, usageType, usageID); +} + + +virSecretPtr +fakeSecretLookupByUUID(virConnectPtr conn, + const unsigned char *uuid) +{ + /* NB: This mocked value could be "tls" or "volume" depending on + * which test is being run, we'll leave at NONE (or 0) */ + return virGetSecret(conn, uuid, VIR_SECRET_USAGE_TYPE_NONE, ""); +} diff --git a/tests/testutilsqemu.h b/tests/testutilsqemu.h index 90632031ff..99d34fcaf5 100644 --- a/tests/testutilsqemu.h +++ b/tests/testutilsqemu.h @@ -188,4 +188,61 @@ testQemuInsertRealCaps(virFileCache *cache, GHashTable *capsCache, GHashTable *schemaCache, GHashTable **schema); + +void +testQemuPrepareDef(virDomainObj *vm, + testQemuInfo *info); + +virStoragePoolPtr +fakeStoragePoolLookupByName(virConnectPtr conn, + const char *name); + +virStorageVolPtr +fakeStorageVolLookupByName(virStoragePoolPtr pool, + const char *name); + +int +fakeStorageVolGetInfo(virStorageVolPtr vol, + virStorageVolInfoPtr info); + +char * +fakeStorageVolGetPath(virStorageVolPtr vol); + +char * +fakeStoragePoolGetXMLDesc(virStoragePoolPtr pool, + unsigned int flags_unused); + +int +fakeStoragePoolIsActive(virStoragePoolPtr pool); + +virNetworkPtr +fakeNetworkLookupByName(virConnectPtr conn, + const char *name); + +char * +fakeNetworkGetXMLDesc(virNetworkPtr network, + unsigned int noflags); + +virNetworkPortPtr +fakeNetworkPortCreateXML(virNetworkPtr net, + const char *xmldesc, + unsigned int noflags); + +char * +fakeNetworkPortGetXMLDesc(virNetworkPortPtr port, + unsigned int noflags); + +unsigned char * +fakeSecretGetValue(virSecretPtr obj, + size_t *value_size, + unsigned int fakeflags); + +virSecretPtr +fakeSecretLookupByUsage(virConnectPtr conn, + int usageType, + const char *usageID); + +virSecretPtr +fakeSecretLookupByUUID(virConnectPtr conn, + const unsigned char *uuid); #endif --=20 2.34.1