2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00
ovs/lib/wmi.h
Alin Serdean da467899ab Windows: Add internal switch port per OVS bridge
This patch updates the following commands in the vswitch:
 ovs-vsctl add-br br-test
 ovs-vsctl del-br br-test

ovs-vsctl add-br br-test:
    This command will now create an internal port on the MSFT virtual switch
  using the WMI interface from Msvm_VirtualEthernetSwitchManagementService
  leveraging the method AddResourceSettings.
    Before creating the actual port, the switch will be queried to see if there
  is not a port already created (good for restarts when restarting the
  vswitch daemon). If there is a port defined it will return success and log
  a message.
    After checking if the port already exists the command will also verify
  if the forwarding extension (windows datapath) is enabled and on a single
  switch. If it is not activated or if it is activated on multiple switches
  it will return an error and a message will be logged.
    After the port was created on the switch, we will disable the adapter on
  the host and rename to the corresponding OVS bridge name for consistency.
    The user will enable and set the values he wants after creation.

ovs-vsctl del-br br-test
    This command will remove an internal port on the MSFT virtual switch
  using the Msvm_VirtualEthernetSwitchManagementService class and executing
  the method RemoveResourceSettings.

Both commands will be blocking until the WMI job is finished, this allows us
to guarantee that the ports are created and their name are set before issuing
a netlink message to the windows datapath.

This patch also includes helpers for normal WMI retrievals and initializations.
Appveyor and documentation has been modified to include the libraries needed
for COM objects.

This patch was tested individually using IMallocSpy and CRT heap checks
to ensure no new memory leaks are introduced.

Tested on the following OS's:
Windows 2012, Windows 2012r2, Windows 2016

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Paul Boca <pboca@cloudbasesolutions.com>
Acked-by: Sairam Venugopal <vsairam@vmware.com>
Signed-off-by: Gurucharan Shetty <guru@ovn.org>
2016-12-20 12:21:24 -08:00

52 lines
1.4 KiB
C

/*
* Copyright (c) 2016 Cloudbase Solutions Srl
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WMI_H
#define WMI_H 1
#include <windefs.h>
#include <Wbemidl.h>
static inline void fill_context(IWbemContext *pContext)
{
VARIANT var;
/* IncludeQualifiers. */
VariantInit(&var);
var.vt = VT_BOOL;
var.boolVal = VARIANT_TRUE;
pContext->lpVtbl->SetValue(pContext, L"IncludeQualifiers", 0, &var);
VariantClear(&var);
VariantInit(&var);
var.vt = VT_I4;
var.lVal = 0;
pContext->lpVtbl->SetValue(pContext, L"PathLevel", 0, &var);
VariantClear(&var);
/* ExcludeSystemProperties. */
VariantInit(&var);
var.vt = VT_BOOL;
var.boolVal = VARIANT_FALSE;
pContext->lpVtbl->SetValue(pContext, L"ExcludeSystemProperties", 0, &var);
VariantClear(&var);
}
boolean create_wmi_port(char *name);
boolean delete_wmi_port(char *name);
#endif /* wmi.h */