mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
ch: Pass net ids explicitly during vm creation
Pass "net_<index>" as net id to CH. This is to have better control over the network configs. This id can be further used in performing operations like restore etc. Signed-off-by: Purna Pavan Chandra <paekkaladevi@linux.microsoft.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
fa66343ef9
commit
3e41cd5e82
@ -278,18 +278,25 @@ virCHMonitorBuildDisksJson(virJSONValue *content, virDomainDef *vmdef)
|
||||
/**
|
||||
* virCHMonitorBuildNetJson:
|
||||
* @net: pointer to a guest network definition
|
||||
* @netindex: index of the guest network definition
|
||||
* @jsonstr: returned network json
|
||||
*
|
||||
* Build net json to send to CH
|
||||
* Returns 0 on success or -1 in case of error
|
||||
*/
|
||||
int
|
||||
virCHMonitorBuildNetJson(virDomainNetDef *net, char **jsonstr)
|
||||
virCHMonitorBuildNetJson(virDomainNetDef *net,
|
||||
int netindex,
|
||||
char **jsonstr)
|
||||
{
|
||||
char macaddr[VIR_MAC_STRING_BUFLEN];
|
||||
g_autoptr(virJSONValue) net_json = virJSONValueNewObject();
|
||||
virDomainNetType actualType = virDomainNetGetActualType(net);
|
||||
|
||||
g_autofree char *id = g_strdup_printf("%s_%d", CH_NET_ID_PREFIX, netindex);
|
||||
if (virJSONValueObjectAppendString(net_json, "id", id) < 0)
|
||||
return -1;
|
||||
|
||||
if (actualType == VIR_DOMAIN_NET_TYPE_ETHERNET &&
|
||||
net->guestIP.nips == 1) {
|
||||
const virNetDevIPAddr *ip;
|
||||
|
@ -42,6 +42,8 @@
|
||||
|
||||
#define VIRCH_THREAD_NAME_LEN 16
|
||||
|
||||
#define CH_NET_ID_PREFIX "net"
|
||||
|
||||
typedef enum {
|
||||
virCHThreadTypeEmulator,
|
||||
virCHThreadTypeVcpu,
|
||||
@ -125,4 +127,6 @@ size_t virCHMonitorGetThreadInfo(virCHMonitor *mon, bool refresh,
|
||||
int virCHMonitorGetIOThreads(virCHMonitor *mon,
|
||||
virDomainIOThreadInfo ***iothreads);
|
||||
int
|
||||
virCHMonitorBuildNetJson(virDomainNetDef *netdef, char **jsonstr);
|
||||
virCHMonitorBuildNetJson(virDomainNetDef *netdef,
|
||||
int netindex,
|
||||
char **jsonstr);
|
||||
|
@ -621,7 +621,7 @@ chProcessAddNetworkDevices(virCHDriver *driver,
|
||||
nicindexes, nnicindexes) < 0)
|
||||
return -1;
|
||||
|
||||
if (virCHMonitorBuildNetJson(vmdef->nets[i], &payload) < 0) {
|
||||
if (virCHMonitorBuildNetJson(vmdef->nets[i], i, &payload) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Failed to build net json"));
|
||||
return -1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user