Skip to content

Commit

Permalink
Drop usage of virtinterfaced
Browse files Browse the repository at this point in the history
virtinterfaced is being deprecated [1], and at least some distros want
to get rid of the dependency.

Fixes cockpit-project#1777

[1] https://listman.redhat.com/archives/libvir-list/2020-December/msg00183.html
  • Loading branch information
martinpitt committed Aug 27, 2024
1 parent 0c7aec3 commit f22e922
Show file tree
Hide file tree
Showing 10 changed files with 2 additions and 133 deletions.
1 change: 0 additions & 1 deletion packaging/cockpit-machines.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Requires: libvirt-daemon-driver-qemu
Requires: libvirt-daemon-driver-network
Requires: libvirt-daemon-driver-nodedev
Requires: libvirt-daemon-driver-storage-core
Requires: (libvirt-daemon-driver-interface if virt-install)
Requires: (libvirt-daemon-config-network if virt-install)
Recommends: libvirt-daemon-driver-storage-disk
%if 0%{?rhel}
Expand Down
8 changes: 0 additions & 8 deletions src/actions/store-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
UNDEFINE_NETWORK,
UNDEFINE_STORAGE_POOL,
UNDEFINE_VM,
UPDATE_ADD_INTERFACE,
UPDATE_ADD_NETWORK,
UPDATE_ADD_NODE_DEVICE,
UPDATE_ADD_STORAGE_POOL,
Expand Down Expand Up @@ -141,13 +140,6 @@ export function updateDomainSnapshots({ connectionName, domainPath, snaps }) {
};
}

export function updateOrAddInterface(props) {
return {
type: UPDATE_ADD_INTERFACE,
payload: { iface: props },
};
}

export function updateOrAddNetwork(props, updateOnly) {
return {
type: UPDATE_ADD_NETWORK,
Expand Down
3 changes: 1 addition & 2 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class AppActive extends React.Component {
}

render() {
const { vms, config, storagePools, systemInfo, ui, networks, nodeDevices, interfaces } = store.getState();
const { vms, config, storagePools, systemInfo, ui, networks, nodeDevices } = store.getState();
const { path, cloudInitSupported, downloadOSSupported, unattendedSupported, unattendedUserLogin, virtInstallAvailable } = this.state;
const combinedVms = [...vms, ...dummyVmsFilter(vms, ui.vms)];
const properties = {
Expand Down Expand Up @@ -337,7 +337,6 @@ class AppActive extends React.Component {
ui={ui}
libvirtVersion={systemInfo.libvirtVersion}
storagePools={storagePools}
interfaces={interfaces}
networks={networks}
actions={vmActions}
resourceHasError={this.state.resourceHasError}
Expand Down
1 change: 0 additions & 1 deletion src/constants/store-action-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ export const SET_NODE_MAX_MEMORY = "SET_NODE_MAX_MEMORY";
export const UNDEFINE_NETWORK = "UNDEFINE_NETWORK";
export const UNDEFINE_STORAGE_POOL = "UNDEFINE_STORAGE_POOL";
export const UNDEFINE_VM = "UNDEFINE_VM";
export const UPDATE_ADD_INTERFACE = "UPDATE_ADD_INTERFACE";
export const UPDATE_ADD_NETWORK = "UPDATE_ADD_NETWORK";
export const UPDATE_ADD_NODE_DEVICE = "UPDATE_ADD_NODE_DEVICE";
export const UPDATE_ADD_VM = "UPDATE_ADD_VM";
Expand Down
8 changes: 1 addition & 7 deletions src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -683,23 +683,17 @@ export function getStorageVolumesUsage(vms, storagePool) {

/**
* Returns a list of potential physical devices suitable as network devices
* by merging all network node devices and interfaces.
*
* @returns {array}
*/
export function getNetworkDevices() {
const { nodeDevices, interfaces } = store.getState();
const devs = [];

nodeDevices.forEach(dev => {
store.getState().nodeDevices.forEach(dev => {
if (dev.capability.type === "net")
devs.push(dev.capability.interface);
});

interfaces.forEach(iface => {
devs.push(iface.name);
});

const uniq = [...new Set(devs)];
uniq.sort();

Expand Down
4 changes: 0 additions & 4 deletions src/libvirtApi/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ import {
Enum,
timeout,
} from "../libvirtApi/helpers.js";
import {
interfaceGetAll,
} from "../libvirtApi/interface.js";
import {
networkGet,
networkGetAll,
Expand Down Expand Up @@ -455,7 +452,6 @@ export function getApiData({ connectionName }) {
return Promise.allSettled([
domainGetAll({ connectionName }),
storagePoolGetAll({ connectionName }),
interfaceGetAll({ connectionName }),
networkGetAll({ connectionName }),
nodeDeviceGetAll({ connectionName }),
getNodeMaxMemory({ connectionName }),
Expand Down
75 changes: 0 additions & 75 deletions src/libvirtApi/interface.js

This file was deleted.

29 changes: 0 additions & 29 deletions src/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {
UNDEFINE_NETWORK,
UNDEFINE_STORAGE_POOL,
UNDEFINE_VM,
UPDATE_ADD_INTERFACE,
UPDATE_ADD_NETWORK,
UPDATE_ADD_NODE_DEVICE,
UPDATE_ADD_VM,
Expand Down Expand Up @@ -93,33 +92,6 @@ function lazyComposedReducer({ parentReducer, getSubreducer, getSubstate, setSub
};
}

function interfaces(state, action) {
state = state || [];

switch (action.type) {
case UPDATE_ADD_INTERFACE: {
const { iface } = action.payload;

if (isObjectEmpty(iface))
return [...state, iface]; // initialize iface to empty object

const connectionName = iface.connectionName;
const index = getFirstIndexOfResource(state, 'name', iface.name, connectionName);
if (index < 0) { // add
const initObjIndex = state.findIndex(obj => isObjectEmpty(obj));
if (initObjIndex >= 0)
state.splice(initObjIndex, 1); // remove empty initial object
return [...state, iface];
}

const updatedIface = Object.assign({}, state[index], iface);
return replaceResource({ state, updatedResource: updatedIface, index });
}
default:
return state;
}
}

function networks(state, action) {
state = state || [];

Expand Down Expand Up @@ -428,7 +400,6 @@ export default combineReducers({
getSubstate: (state) => state.providerState,
setSubstate: (state, subState) => Object.assign({}, state, { providerState: subState }),
}),
interfaces,
networks,
nodeDevices,
vms,
Expand Down
1 change: 0 additions & 1 deletion test/browser/browser.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ sh -x test/vm.install

if [ "${PLATFORM_ID:-}" != "platform:el8" ]; then
# https://gitlab.com/libvirt/libvirt/-/issues/219
systemctl start virtinterfaced.socket
systemctl start virtnetworkd.socket
systemctl start virtnodedevd.socket
systemctl start virtstoraged.socket
Expand Down
5 changes: 0 additions & 5 deletions test/vm.install
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ if grep -q 'ID=debian' /usr/lib/os-release; then
echo '* soft core unlimited' >> /etc/security/limits.conf
fi

if grep -q 'ID="opensuse' /usr/lib/os-release; then
# Make sure virtinterfaced.socket is enabled
systemctl enable --now virtinterfaced.socket
fi

systemctl enable cockpit.socket

# don't force https:// (self-signed cert)
Expand Down

0 comments on commit f22e922

Please sign in to comment.