|
|
3a9410 |
From a259f2fc77dac6fa2fd7910d4c96d231b0ea3182 Mon Sep 17 00:00:00 2001
|
|
|
3a9410 |
Message-Id: <a259f2fc77dac6fa2fd7910d4c96d231b0ea3182@dist-git>
|
|
|
3a9410 |
From: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
3a9410 |
Date: Fri, 13 May 2022 12:31:01 +0200
|
|
|
3a9410 |
Subject: [PATCH] util: refactor virDomainDeviceCCWAddress into virccw.h
|
|
|
3a9410 |
|
|
|
3a9410 |
Refactor ccw data structure virDomainDeviceCCWAddress into util virccw.h
|
|
|
3a9410 |
and rename it as virCCWDeviceAddress.
|
|
|
3a9410 |
|
|
|
3a9410 |
Signed-off-by: Boris Fiuczynski <fiuczy@linux.ibm.com>
|
|
|
3a9410 |
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
3a9410 |
(cherry picked from commit 45a8e3988f7b087b3b721e74ce5e6b5658b2b424)
|
|
|
3a9410 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2165011
|
|
|
3a9410 |
Signed-off-by: Thomas Huth <thuth@redhat.com>
|
|
|
3a9410 |
---
|
|
|
3a9410 |
src/conf/device_conf.c | 8 +++----
|
|
|
3a9410 |
src/conf/device_conf.h | 19 ++++++-----------
|
|
|
3a9410 |
src/conf/domain_addr.c | 6 +++---
|
|
|
3a9410 |
src/conf/domain_addr.h | 4 ++--
|
|
|
3a9410 |
src/conf/domain_conf.c | 6 +++---
|
|
|
3a9410 |
src/conf/domain_conf.h | 6 +++---
|
|
|
3a9410 |
src/node_device/node_device_driver.c | 2 +-
|
|
|
3a9410 |
src/qemu/qemu_agent.c | 4 ++--
|
|
|
3a9410 |
src/qemu/qemu_agent.h | 2 +-
|
|
|
3a9410 |
src/util/virccw.h | 31 ++++++++++++++++++++++++++++
|
|
|
3a9410 |
10 files changed, 56 insertions(+), 32 deletions(-)
|
|
|
3a9410 |
create mode 100644 src/util/virccw.h
|
|
|
3a9410 |
|
|
|
3a9410 |
diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
|
|
|
3a9410 |
index cb523d3a0d..92b908b2e6 100644
|
|
|
3a9410 |
--- a/src/conf/device_conf.c
|
|
|
3a9410 |
+++ b/src/conf/device_conf.c
|
|
|
3a9410 |
@@ -259,7 +259,7 @@ virPCIDeviceAddressFormat(virBuffer *buf,
|
|
|
3a9410 |
}
|
|
|
3a9410 |
|
|
|
3a9410 |
bool
|
|
|
3a9410 |
-virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddress *addr)
|
|
|
3a9410 |
+virDomainDeviceCCWAddressIsValid(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
return addr->cssid <= VIR_DOMAIN_DEVICE_CCW_MAX_CSSID &&
|
|
|
3a9410 |
addr->ssid <= VIR_DOMAIN_DEVICE_CCW_MAX_SSID &&
|
|
|
3a9410 |
@@ -268,7 +268,7 @@ virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddress *addr)
|
|
|
3a9410 |
|
|
|
3a9410 |
int
|
|
|
3a9410 |
virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *addr)
|
|
|
3a9410 |
+ virCCWDeviceAddress *addr)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
int cssid;
|
|
|
3a9410 |
int ssid;
|
|
|
3a9410 |
@@ -307,8 +307,8 @@ virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
|
|
|
3a9410 |
}
|
|
|
3a9410 |
|
|
|
3a9410 |
bool
|
|
|
3a9410 |
-virDomainDeviceCCWAddressEqual(virDomainDeviceCCWAddress *addr1,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *addr2)
|
|
|
3a9410 |
+virDomainDeviceCCWAddressEqual(virCCWDeviceAddress *addr1,
|
|
|
3a9410 |
+ virCCWDeviceAddress *addr2)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
if (addr1->cssid == addr2->cssid &&
|
|
|
3a9410 |
addr1->ssid == addr2->ssid &&
|
|
|
3a9410 |
diff --git a/src/conf/device_conf.h b/src/conf/device_conf.h
|
|
|
3a9410 |
index b6b710d313..60d90bbf19 100644
|
|
|
3a9410 |
--- a/src/conf/device_conf.h
|
|
|
3a9410 |
+++ b/src/conf/device_conf.h
|
|
|
3a9410 |
@@ -27,6 +27,7 @@
|
|
|
3a9410 |
#include "internal.h"
|
|
|
3a9410 |
#include "virthread.h"
|
|
|
3a9410 |
#include "virbuffer.h"
|
|
|
3a9410 |
+#include "virccw.h"
|
|
|
3a9410 |
#include "virpci.h"
|
|
|
3a9410 |
#include "virnetdev.h"
|
|
|
3a9410 |
#include "virenum.h"
|
|
|
3a9410 |
@@ -73,14 +74,6 @@ struct _virDomainDeviceVirtioSerialAddress {
|
|
|
3a9410 |
#define VIR_DOMAIN_DEVICE_CCW_MAX_SSID 3
|
|
|
3a9410 |
#define VIR_DOMAIN_DEVICE_CCW_MAX_DEVNO 65535
|
|
|
3a9410 |
|
|
|
3a9410 |
-typedef struct _virDomainDeviceCCWAddress virDomainDeviceCCWAddress;
|
|
|
3a9410 |
-struct _virDomainDeviceCCWAddress {
|
|
|
3a9410 |
- unsigned int cssid;
|
|
|
3a9410 |
- unsigned int ssid;
|
|
|
3a9410 |
- unsigned int devno;
|
|
|
3a9410 |
- bool assigned;
|
|
|
3a9410 |
-};
|
|
|
3a9410 |
-
|
|
|
3a9410 |
typedef struct _virDomainDeviceCcidAddress virDomainDeviceCcidAddress;
|
|
|
3a9410 |
struct _virDomainDeviceCcidAddress {
|
|
|
3a9410 |
unsigned int controller;
|
|
|
3a9410 |
@@ -136,7 +129,7 @@ struct _virDomainDeviceInfo {
|
|
|
3a9410 |
virDomainDeviceCcidAddress ccid;
|
|
|
3a9410 |
virDomainDeviceUSBAddress usb;
|
|
|
3a9410 |
virDomainDeviceSpaprVioAddress spaprvio;
|
|
|
3a9410 |
- virDomainDeviceCCWAddress ccw;
|
|
|
3a9410 |
+ virCCWDeviceAddress ccw;
|
|
|
3a9410 |
virDomainDeviceISAAddress isa;
|
|
|
3a9410 |
virDomainDeviceDimmAddress dimm;
|
|
|
3a9410 |
} addr;
|
|
|
3a9410 |
@@ -204,11 +197,11 @@ void virPCIDeviceAddressFormat(virBuffer *buf,
|
|
|
3a9410 |
virPCIDeviceAddress addr,
|
|
|
3a9410 |
bool includeTypeInAddr);
|
|
|
3a9410 |
|
|
|
3a9410 |
-bool virDomainDeviceCCWAddressIsValid(virDomainDeviceCCWAddress *addr);
|
|
|
3a9410 |
+bool virDomainDeviceCCWAddressIsValid(virCCWDeviceAddress *addr);
|
|
|
3a9410 |
int virDomainDeviceCCWAddressParseXML(xmlNodePtr node,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *addr);
|
|
|
3a9410 |
-bool virDomainDeviceCCWAddressEqual(virDomainDeviceCCWAddress *addr1,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *addr2);
|
|
|
3a9410 |
+ virCCWDeviceAddress *addr);
|
|
|
3a9410 |
+bool virDomainDeviceCCWAddressEqual(virCCWDeviceAddress *addr1,
|
|
|
3a9410 |
+ virCCWDeviceAddress *addr2);
|
|
|
3a9410 |
#define VIR_CCW_DEVICE_ADDRESS_FMT "%x.%x.%04x"
|
|
|
3a9410 |
|
|
|
3a9410 |
int virDomainDeviceDriveAddressParseXML(xmlNodePtr node,
|
|
|
3a9410 |
diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
|
|
|
3a9410 |
index 49745ba881..d584d3b8a8 100644
|
|
|
3a9410 |
--- a/src/conf/domain_addr.c
|
|
|
3a9410 |
+++ b/src/conf/domain_addr.c
|
|
|
3a9410 |
@@ -1287,15 +1287,15 @@ virDomainPCIAddressSetAllMulti(virDomainDef *def)
|
|
|
3a9410 |
|
|
|
3a9410 |
|
|
|
3a9410 |
char*
|
|
|
3a9410 |
-virDomainCCWAddressAsString(virDomainDeviceCCWAddress *addr)
|
|
|
3a9410 |
+virDomainCCWAddressAsString(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
return g_strdup_printf("%x.%x.%04x", addr->cssid, addr->ssid, addr->devno);
|
|
|
3a9410 |
}
|
|
|
3a9410 |
|
|
|
3a9410 |
static int
|
|
|
3a9410 |
-virDomainCCWAddressIncrement(virDomainDeviceCCWAddress *addr)
|
|
|
3a9410 |
+virDomainCCWAddressIncrement(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
- virDomainDeviceCCWAddress ccwaddr = *addr;
|
|
|
3a9410 |
+ virCCWDeviceAddress ccwaddr = *addr;
|
|
|
3a9410 |
|
|
|
3a9410 |
/* We are not touching subchannel sets and channel subsystems */
|
|
|
3a9410 |
if (++ccwaddr.devno > VIR_DOMAIN_DEVICE_CCW_MAX_DEVNO)
|
|
|
3a9410 |
diff --git a/src/conf/domain_addr.h b/src/conf/domain_addr.h
|
|
|
3a9410 |
index 814b556024..c8d069e07e 100644
|
|
|
3a9410 |
--- a/src/conf/domain_addr.h
|
|
|
3a9410 |
+++ b/src/conf/domain_addr.h
|
|
|
3a9410 |
@@ -195,7 +195,7 @@ void virDomainPCIAddressSetAllMulti(virDomainDef *def)
|
|
|
3a9410 |
|
|
|
3a9410 |
struct _virDomainCCWAddressSet {
|
|
|
3a9410 |
GHashTable *defined;
|
|
|
3a9410 |
- virDomainDeviceCCWAddress next;
|
|
|
3a9410 |
+ virCCWDeviceAddress next;
|
|
|
3a9410 |
};
|
|
|
3a9410 |
typedef struct _virDomainCCWAddressSet virDomainCCWAddressSet;
|
|
|
3a9410 |
|
|
|
3a9410 |
@@ -205,7 +205,7 @@ int virDomainCCWAddressAssign(virDomainDeviceInfo *dev,
|
|
|
3a9410 |
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
|
|
3a9410 |
void virDomainCCWAddressSetFree(virDomainCCWAddressSet *addrs);
|
|
|
3a9410 |
|
|
|
3a9410 |
-char* virDomainCCWAddressAsString(virDomainDeviceCCWAddress *addr)
|
|
|
3a9410 |
+char* virDomainCCWAddressAsString(virCCWDeviceAddress *addr)
|
|
|
3a9410 |
ATTRIBUTE_NONNULL(1);
|
|
|
3a9410 |
|
|
|
3a9410 |
virDomainCCWAddressSet *
|
|
|
3a9410 |
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
|
|
|
3a9410 |
index 95afd9226e..ad3bd56da0 100644
|
|
|
3a9410 |
--- a/src/conf/domain_conf.c
|
|
|
3a9410 |
+++ b/src/conf/domain_conf.c
|
|
|
3a9410 |
@@ -15541,7 +15541,7 @@ virDomainDiskControllerMatch(int controller_type, int disk_bus)
|
|
|
3a9410 |
int
|
|
|
3a9410 |
virDomainDiskIndexByAddress(virDomainDef *def,
|
|
|
3a9410 |
virPCIDeviceAddress *pci_address,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *ccw_addr,
|
|
|
3a9410 |
+ virCCWDeviceAddress *ccw_addr,
|
|
|
3a9410 |
unsigned int bus, unsigned int target,
|
|
|
3a9410 |
unsigned int unit)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
@@ -15585,7 +15585,7 @@ virDomainDiskIndexByAddress(virDomainDef *def,
|
|
|
3a9410 |
virDomainDiskDef *
|
|
|
3a9410 |
virDomainDiskByAddress(virDomainDef *def,
|
|
|
3a9410 |
virPCIDeviceAddress *pci_address,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *ccw_addr,
|
|
|
3a9410 |
+ virCCWDeviceAddress *ccw_addr,
|
|
|
3a9410 |
unsigned int bus,
|
|
|
3a9410 |
unsigned int target,
|
|
|
3a9410 |
unsigned int unit)
|
|
|
3a9410 |
@@ -16184,7 +16184,7 @@ virDomainControllerFindByType(virDomainDef *def,
|
|
|
3a9410 |
|
|
|
3a9410 |
int
|
|
|
3a9410 |
virDomainControllerFindByCCWAddress(virDomainDef *def,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *addr)
|
|
|
3a9410 |
+ virCCWDeviceAddress *addr)
|
|
|
3a9410 |
{
|
|
|
3a9410 |
size_t i;
|
|
|
3a9410 |
|
|
|
3a9410 |
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
|
|
|
3a9410 |
index 45976beb2b..930af36868 100644
|
|
|
3a9410 |
--- a/src/conf/domain_conf.h
|
|
|
3a9410 |
+++ b/src/conf/domain_conf.h
|
|
|
3a9410 |
@@ -3622,12 +3622,12 @@ void virDomainRNGDefFree(virDomainRNGDef *def);
|
|
|
3a9410 |
|
|
|
3a9410 |
int virDomainDiskIndexByAddress(virDomainDef *def,
|
|
|
3a9410 |
virPCIDeviceAddress *pci_controller,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *ccw_addr,
|
|
|
3a9410 |
+ virCCWDeviceAddress *ccw_addr,
|
|
|
3a9410 |
unsigned int bus, unsigned int target,
|
|
|
3a9410 |
unsigned int unit);
|
|
|
3a9410 |
virDomainDiskDef *virDomainDiskByAddress(virDomainDef *def,
|
|
|
3a9410 |
virPCIDeviceAddress *pci_controller,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *ccw_addr,
|
|
|
3a9410 |
+ virCCWDeviceAddress *ccw_addr,
|
|
|
3a9410 |
unsigned int bus,
|
|
|
3a9410 |
unsigned int target,
|
|
|
3a9410 |
unsigned int unit);
|
|
|
3a9410 |
@@ -3712,7 +3712,7 @@ void virDomainControllerInsertPreAlloced(virDomainDef *def,
|
|
|
3a9410 |
int virDomainControllerFind(const virDomainDef *def, int type, int idx);
|
|
|
3a9410 |
int virDomainControllerFindByType(virDomainDef *def, int type);
|
|
|
3a9410 |
int virDomainControllerFindByCCWAddress(virDomainDef *def,
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *addr);
|
|
|
3a9410 |
+ virCCWDeviceAddress *addr);
|
|
|
3a9410 |
int virDomainControllerFindByPCIAddress(virDomainDef *def,
|
|
|
3a9410 |
virPCIDeviceAddress *addr);
|
|
|
3a9410 |
int virDomainControllerFindUnusedIndex(virDomainDef const *def, int type);
|
|
|
3a9410 |
diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c
|
|
|
3a9410 |
index d19ed7d948..b0abf59618 100644
|
|
|
3a9410 |
--- a/src/node_device/node_device_driver.c
|
|
|
3a9410 |
+++ b/src/node_device/node_device_driver.c
|
|
|
3a9410 |
@@ -676,7 +676,7 @@ nodeDeviceObjFormatAddress(virNodeDeviceObj *obj)
|
|
|
3a9410 |
}
|
|
|
3a9410 |
|
|
|
3a9410 |
case VIR_NODE_DEV_CAP_CSS_DEV: {
|
|
|
3a9410 |
- virDomainDeviceCCWAddress ccw_addr = {
|
|
|
3a9410 |
+ virCCWDeviceAddress ccw_addr = {
|
|
|
3a9410 |
.cssid = caps->data.ccw_dev.cssid,
|
|
|
3a9410 |
.ssid = caps->data.ccw_dev.ssid,
|
|
|
3a9410 |
.devno = caps->data.ccw_dev.devno
|
|
|
3a9410 |
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
|
|
|
3a9410 |
index 8a55044c9e..db844148a6 100644
|
|
|
3a9410 |
--- a/src/qemu/qemu_agent.c
|
|
|
3a9410 |
+++ b/src/qemu/qemu_agent.c
|
|
|
3a9410 |
@@ -1769,9 +1769,9 @@ qemuAgentGetDiskAddress(virJSONValue *json)
|
|
|
3a9410 |
GET_DISK_ADDR(pci, &addr->pci_controller.function, "function");
|
|
|
3a9410 |
|
|
|
3a9410 |
if ((ccw = virJSONValueObjectGet(json, "ccw-address"))) {
|
|
|
3a9410 |
- g_autofree virDomainDeviceCCWAddress *ccw_addr = NULL;
|
|
|
3a9410 |
+ g_autofree virCCWDeviceAddress *ccw_addr = NULL;
|
|
|
3a9410 |
|
|
|
3a9410 |
- ccw_addr = g_new0(virDomainDeviceCCWAddress, 1);
|
|
|
3a9410 |
+ ccw_addr = g_new0(virCCWDeviceAddress, 1);
|
|
|
3a9410 |
|
|
|
3a9410 |
GET_DISK_ADDR(ccw, &ccw_addr->cssid, "cssid");
|
|
|
3a9410 |
if (ccw_addr->cssid == 0) /* Guest CSSID 0 is 0xfe on host */
|
|
|
3a9410 |
diff --git a/src/qemu/qemu_agent.h b/src/qemu/qemu_agent.h
|
|
|
3a9410 |
index 862f6b0a95..c07d8507ba 100644
|
|
|
3a9410 |
--- a/src/qemu/qemu_agent.h
|
|
|
3a9410 |
+++ b/src/qemu/qemu_agent.h
|
|
|
3a9410 |
@@ -72,7 +72,7 @@ struct _qemuAgentDiskAddress {
|
|
|
3a9410 |
unsigned int target;
|
|
|
3a9410 |
unsigned int unit;
|
|
|
3a9410 |
char *devnode;
|
|
|
3a9410 |
- virDomainDeviceCCWAddress *ccw_addr;
|
|
|
3a9410 |
+ virCCWDeviceAddress *ccw_addr;
|
|
|
3a9410 |
};
|
|
|
3a9410 |
void qemuAgentDiskAddressFree(qemuAgentDiskAddress *addr);
|
|
|
3a9410 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuAgentDiskAddress, qemuAgentDiskAddressFree);
|
|
|
3a9410 |
diff --git a/src/util/virccw.h b/src/util/virccw.h
|
|
|
3a9410 |
new file mode 100644
|
|
|
3a9410 |
index 0000000000..701e13284b
|
|
|
3a9410 |
--- /dev/null
|
|
|
3a9410 |
+++ b/src/util/virccw.h
|
|
|
3a9410 |
@@ -0,0 +1,31 @@
|
|
|
3a9410 |
+/*
|
|
|
3a9410 |
+ * virccw.h: helper APIs for managing host CCW devices
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * Copyright (C) 2022 IBM Corporation
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * This library is free software; you can redistribute it and/or
|
|
|
3a9410 |
+ * modify it under the terms of the GNU Lesser General Public
|
|
|
3a9410 |
+ * License as published by the Free Software Foundation; either
|
|
|
3a9410 |
+ * version 2.1 of the License, or (at your option) any later version.
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * This library is distributed in the hope that it will be useful,
|
|
|
3a9410 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
3a9410 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
3a9410 |
+ * Lesser General Public License for more details.
|
|
|
3a9410 |
+ *
|
|
|
3a9410 |
+ * You should have received a copy of the GNU Lesser General Public
|
|
|
3a9410 |
+ * License along with this library. If not, see
|
|
|
3a9410 |
+ * <http://www.gnu.org/licenses/>.
|
|
|
3a9410 |
+ */
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+#pragma once
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+#include "internal.h"
|
|
|
3a9410 |
+
|
|
|
3a9410 |
+typedef struct _virCCWDeviceAddress virCCWDeviceAddress;
|
|
|
3a9410 |
+struct _virCCWDeviceAddress {
|
|
|
3a9410 |
+ unsigned int cssid;
|
|
|
3a9410 |
+ unsigned int ssid;
|
|
|
3a9410 |
+ unsigned int devno;
|
|
|
3a9410 |
+ bool assigned;
|
|
|
3a9410 |
+};
|
|
|
3a9410 |
--
|
|
|
3a9410 |
2.39.1
|
|
|
3a9410 |
|