You are not logged in.
Pages: 1
EDIT
[Unit]
Description=activite kvm network NIC
Requires=network.target
After=network.target
After=libvirtd.service
[Service]
Type=idle
ExecStart=/usr/lib/systemd/scripts/virbr0.sh
[Install]
WantedBy=multi-user.targetBy changing the Type to idle solve the problem.
I have install qemu and for some reason, the default NIC interface will not be up.
Here is the start up script place in
/usr/lib/systemd/scripts#!/bin/bash
# virbr0.sh
virsh net-start defaultAnd the service file place in
/etc/systemd/system[Unit]
Description=bring up virbr0 virbr0.service
Requires=network.target
After=network.target
After=libvirtd.service
[Service]
Type=simple
ExecStart=/usr/lib/systemd/scripts/virbr0.sh
[Install]
WantedBy=multi-user.targetI did
systemctl enable virbr0.serivcehowever, when restart the interface is not up
if I do
systemctl start virbr0manually, the interface will be up.
Please help! Thanks everyone.
Last edited by wudaown (2017-05-08 13:17:50)
Offline
systemctl enable virbr0.serivceserivce?
Offline
What does:
systemctl status virbr0or
journalctl -b -u virbr0say after a reboot?
Not sure what `virsh net-start default` does exactly. If it requires a physical NIC to be configured beforehand, After=network.target might not be useful:
[tom@localhost ~]$ journalctl -b -u network.target
-- Logs begin at Wed 2017-05-03 23:54:40 CST, end at Mon 2017-05-08 21:06:56 CST. --
May 08 20:59:29 localhost systemd[1]: Reached target Network.
[tom@localhost ~]$ journalctl -b -u systemd-networkd
-- Logs begin at Wed 2017-05-03 23:54:40 CST, end at Mon 2017-05-08 21:06:56 CST. --
May 08 20:59:29 localhost systemd[1]: Starting Network Service...
May 08 20:59:29 localhost systemd-networkd[362]: Enumeration completed
May 08 20:59:29 localhost systemd[1]: Started Network Service.
May 08 20:59:29 localhost systemd-networkd[362]: enp2s0: Renamed to eth0
May 08 20:59:29 localhost systemd-networkd[362]: eth0: Renamed to enp2s0
May 08 20:59:29 localhost systemd-networkd[362]: enp2s0: IPv6 enabled for interface: Success
May 08 20:59:32 localhost systemd-networkd[362]: enp2s0: Gained carrier
May 08 20:59:34 localhost systemd-networkd[362]: enp2s0: Gained IPv6LL
May 08 20:59:34 localhost systemd-networkd[362]: enp2s0: DHCPv4 address 192.168.0.140/23 via 192.168.0.254
May 08 20:59:47 localhost systemd-networkd[362]: enp2s0: ConfiguredSee the timestamps. Requires=network.target does not make much sense here either.
Also why don't you do this instead (though not really relevant to your problem I suppose):
ExecStart=/usr/bin/virsh net-start defaultLast edited by tom.ty89 (2017-05-08 13:14:56)
Offline
systemctl enable virbr0.serivceserivce?
systemctl enable virbr0.serviceis what i did.
Offline
What does:
systemctl status virbr0or
journalctl -b -u virbr0say after a reboot?
-- Logs begin at Wed 2017-05-03 21:05:45 +08, end at Mon 2017-05-08 21:10:30 +08. --
5月 08 21:10:21 wudaown-MiBook systemd[1]: Started activite kvm network NIC.
5月 08 21:10:21 wudaown-MiBook virbr0.sh[506]: 错误:连接到管理程序失败
5月 08 21:10:21 wudaown-MiBook virbr0.sh[506]: 错误:将插槽连接到 '/var/run/libvirt/libvirt-sock' 失败: 没有那个文件或目录
5月 08 21:10:21 wudaown-MiBook systemd[1]: virbr0.service: Main process exited, code=exited, status=1/FAILURE
5月 08 21:10:21 wudaown-MiBook systemd[1]: virbr0.service: Unit entered failed state.
5月 08 21:10:21 wudaown-MiBook systemd[1]: virbr0.service: Failed with result 'exit-code'.I am sorry that it is in chinese. But it meas that connection to management program for first line. connecting socket to '/var/run/libvirt/libvirt.-sock' failed, no such file or directory for second line.
Thanks
EDIT
[wudaown:~]->>> ls /var/run/libvirt
hostdevmgr/ network/ storage/ uml-guest/ libvirt-sock= virtlockd-sock=
lxc/ qemu/ uml/ libvirt-admin-sock= libvirt-sock-ro= virtlogd-sock=I actually does have the socket. Does that mean i start the service too early?
Last edited by wudaown (2017-05-08 13:14:28)
Offline
... 5月 08 21:10:21 wudaown-MiBook virbr0.sh[506]: 错误:连接到管理程序失败 5月 08 21:10:21 wudaown-MiBook virbr0.sh[506]: 错误:将插槽连接到 '/var/run/libvirt/libvirt-sock' 失败: 没有那个文件或目录 ...I am sorry that it is in chinese. But it meas that connection to management program for first line. connecting socket to '/var/run/libvirt/libvirt.-sock' failed, no such file or directory for second line.
Thanks
EDIT
[wudaown:~]->>> ls /var/run/libvirt hostdevmgr/ network/ storage/ uml-guest/ libvirt-sock= virtlockd-sock= lxc/ qemu/ uml/ libvirt-admin-sock= libvirt-sock-ro= virtlogd-sock=I actually does have the socket. Does that mean i start the service too early?
Well /var/run/libvirt/libvirt-sock is created when libvirtd.service is started (and destroyed when it is stopped). Theoretically After=libvirtd.service should be sufficient, so I am not sure what has gone wrong...
P.S. What's with all those "=" in the names of those sock files?
Offline
You sure Type=idle is the answer?
[tom@localhost ~]$ cat /etc/systemd/system/virtb.service
[Unit]
After=libvirtd.service
[Service]
Type=idle
ExecStart=/usr/bin/ls -l /run/libvirt/libvirt-sock
[Install]
WantedBy=multi-user.targetAfter a reboot:
[tom@localhost ~]$ systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2017-05-08 22:06:48 CST; 27s ago
Docs: man:libvirtd(8)
http://libvirt.org
Main PID: 371 (libvirtd)
Tasks: 16 (limit: 4915)
CGroup: /system.slice/libvirtd.service
└─371 /usr/bin/libvirtd
May 08 22:06:48 localhost systemd[1]: Started Virtualization daemon.
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.155+0000: 390: info : libvirt version: 3.2.0
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.155+0000: 390: info : hostname: localhost
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.155+0000: 390: error : dnsmasqCapsRefreshInternal:741 : Cannot check dnsmasq binary /usr/bin/dnsmasq: No such file or directory
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.332+0000: 390: error : virFirewallValidateBackend:193 : direct firewall backend requested, but /sbin/ebtables is not available: No such file or direct
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.332+0000: 390: error : virFirewallApply:916 : internal error: Failed to initialize a valid firewall backend
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.353+0000: 390: error : virSysinfoReadX86:999 : internal error: Failed to find path for dmidecode binary
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.382+0000: 390: warning : virGetGroupIDByName:1072 : Group record for user '78' was not found: Invalid argument
May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.475+0000: 390: error : virSysinfoReadX86:999 : internal error: Failed to find path for dmidecode binary
[tom@localhost ~]$ systemctl status virtb
● virtb.service
Loaded: loaded (/etc/systemd/system/virtb.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Mon 2017-05-08 22:06:48 CST; 32s ago
Process: 372 ExecStart=/usr/bin/ls -l /run/libvirt/libvirt-sock (code=exited, status=2)
Main PID: 372 (code=exited, status=2)
May 08 22:06:48 localhost systemd[1]: Started virtb.service.
May 08 22:06:48 localhost ls[372]: /usr/bin/ls: cannot access '/run/libvirt/libvirt-sock': No such file or directory
May 08 22:06:48 localhost systemd[1]: virtb.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
May 08 22:06:48 localhost systemd[1]: virtb.service: Unit entered failed state.
May 08 22:06:48 localhost systemd[1]: virtb.service: Failed with result 'exit-code'.
[tom@localhost ~]$ sudo systemctl start virtb
[tom@localhost ~]$ systemctl status virtb
● virtb.service
Loaded: loaded (/etc/systemd/system/virtb.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Mon 2017-05-08 22:07:27 CST; 7s ago
Process: 487 ExecStart=/usr/bin/ls -l /run/libvirt/libvirt-sock (code=exited, status=0/SUCCESS)
Main PID: 487 (code=exited, status=0/SUCCESS)
May 08 22:07:27 localhost systemd[1]: Started virtb.service.
May 08 22:07:27 localhost ls[487]: srwxrwxrwx 1 root root 0 May 8 22:06 /run/libvirt/libvirt-sockLast edited by tom.ty89 (2017-05-08 14:11:50)
Offline
You sure Type=idle is the answer?
[tom@localhost ~]$ cat /etc/systemd/system/virtb.service [Unit] After=libvirtd.service [Service] Type=idle ExecStart=/usr/bin/ls -l /run/libvirt/libvirt-sock [Install] WantedBy=multi-user.targetAfter a reboot:
[tom@localhost ~]$ systemctl status libvirtd ● libvirtd.service - Virtualization daemon Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2017-05-08 22:06:48 CST; 27s ago Docs: man:libvirtd(8) http://libvirt.org Main PID: 371 (libvirtd) Tasks: 16 (limit: 4915) CGroup: /system.slice/libvirtd.service └─371 /usr/bin/libvirtd May 08 22:06:48 localhost systemd[1]: Started Virtualization daemon. May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.155+0000: 390: info : libvirt version: 3.2.0 May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.155+0000: 390: info : hostname: localhost May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.155+0000: 390: error : dnsmasqCapsRefreshInternal:741 : Cannot check dnsmasq binary /usr/bin/dnsmasq: No such file or directory May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.332+0000: 390: error : virFirewallValidateBackend:193 : direct firewall backend requested, but /sbin/ebtables is not available: No such file or direct May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.332+0000: 390: error : virFirewallApply:916 : internal error: Failed to initialize a valid firewall backend May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.353+0000: 390: error : virSysinfoReadX86:999 : internal error: Failed to find path for dmidecode binary May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.382+0000: 390: warning : virGetGroupIDByName:1072 : Group record for user '78' was not found: Invalid argument May 08 22:06:50 localhost libvirtd[371]: 2017-05-08 14:06:50.475+0000: 390: error : virSysinfoReadX86:999 : internal error: Failed to find path for dmidecode binary [tom@localhost ~]$ systemctl status virtb ● virtb.service Loaded: loaded (/etc/systemd/system/virtb.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Mon 2017-05-08 22:06:48 CST; 32s ago Process: 372 ExecStart=/usr/bin/ls -l /run/libvirt/libvirt-sock (code=exited, status=2) Main PID: 372 (code=exited, status=2) May 08 22:06:48 localhost systemd[1]: Started virtb.service. May 08 22:06:48 localhost ls[372]: /usr/bin/ls: cannot access '/run/libvirt/libvirt-sock': No such file or directory May 08 22:06:48 localhost systemd[1]: virtb.service: Main process exited, code=exited, status=2/INVALIDARGUMENT May 08 22:06:48 localhost systemd[1]: virtb.service: Unit entered failed state. May 08 22:06:48 localhost systemd[1]: virtb.service: Failed with result 'exit-code'. [tom@localhost ~]$ sudo systemctl start virtb [tom@localhost ~]$ systemctl status virtb ● virtb.service Loaded: loaded (/etc/systemd/system/virtb.service; enabled; vendor preset: disabled) Active: inactive (dead) since Mon 2017-05-08 22:07:27 CST; 7s ago Process: 487 ExecStart=/usr/bin/ls -l /run/libvirt/libvirt-sock (code=exited, status=0/SUCCESS) Main PID: 487 (code=exited, status=0/SUCCESS) May 08 22:07:27 localhost systemd[1]: Started virtb.service. May 08 22:07:27 localhost ls[487]: srwxrwxrwx 1 root root 0 May 8 22:06 /run/libvirt/libvirt-sock
that works for me.
anyway, for yours. libvirtd required firewalld dnsmasq ebtables iptables to be installed.
[wudaown:/etc/systemd/system]->>> systemctl status virtb
Unit virtb.service could not be found.and i don't have this virtb.service. strange ...
[wudaown:/etc/systemd/system]->>> systemctl status libvirtd.service
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2017-05-08 21:53:36 +08; 1h 10min ago
Docs: man:libvirtd(8)
[url]http://libvirt.org[/url]
Main PID: 405 (libvirtd)
Tasks: 19 (limit: 4915)
CGroup: /system.slice/libvirtd.service
├─405 /usr/bin/libvirtd
├─659 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
└─660 /usr/bin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelperLast edited by wudaown (2017-05-08 15:06:21)
Offline
libvirtd required firewalld dnsmasq ebtables iptables to be installed.
Well it's not really relevant here. libvirtd.service was started successfully. Though perhaps with those installed, libvirtd can be completely started more quickly so it would have the sock file created soon enough for virtb.service. I even tried that but it does not help on my system.
I suspect that you just "happen" to have eliminated the race condition. I mean like, Type=idle (and/or something else) did make virtbr0 start a bit later and/or libvirtd a bit earlier so things worked out. I don't see how Type=idle is the right / a reliable way to fix it anyway, since it does not make virtbr0 become aware of whether the sock file has been created yet or wait for libvirtd to have that done, that simply isn't what it could do.
So all I can say is, if you choose to just stick with it, you better have your finger crossed that it wouldn't fail on any random boot (that said, I guess it wouldn't matter much if it isn't some "production" environment).
i don't have this virtb.service. strange ...
It's just a test unit I wrote.
Last edited by tom.ty89 (2017-05-09 03:44:03)
Offline
Pages: 1