I'm using a USB-modem to connect a virtual machine with the internet. So host and guest do not share the same IP/network. I emulate by qemu-kvm
, device forwarding works great with *-usb -usbdevice host:1c9e:9603*
. The VM uses Ubuntu 10.04, Host 11.10.
Unfortunately the modem unmounts after ~3 days. Obviously, from now on no connection can be established. After the VM reboots, a connection is possible again.
nmcli
can be used to establish an internet connection and check whether its still active.
But how do I remount the device/modem with a small bash script?
The syslog below shows how the device unplugs after being ~3 days in use:
pppd[1369]: LCP terminated by peer
pppd[1369]: Connect time 1104.9 minutes.
pppd[1369]: Sent 1279 bytes, received 790 bytes.
kernel: [66423.705380] device ppp0 left promiscuous mode
pppd[1369]: Modem hangup
pppd[1369]: Connection terminated.
avahi-daemon[424]: Withdrawing workstation service for ppp0.
modem-manager[483]: <info> (ttyUSB2) closing serial port...
NetworkManager[431]: SCPlugin-Ifupdown: devices removed (path: /sys/devices/virtual/net/ppp0, iface: ppp0)
NetworkManager[431]: <info> (ttyUSB2): now unmanaged
NetworkManager[431]: <info> (ttyUSB2): device state change: 8 -> 1 (reason 36)
NetworkManager[431]: <info> (ttyUSB2): deactivating device (reason: 36).
NetworkManager[431]: <warn> could not read ppp stats: No such device
NetworkManager[431]: <info> (ttyUSB2): cleaning up...
NetworkManager[431]: <info> (ttyUSB2): taking down device.
NetworkManager[431]: <info> Unmanaged Device found; state CONNECTED forced. (see http://bugs.launchpad.net/bugs/191889)
nm-dispatcher.action: Error in get_property: Method "Get" with signature "ss" on interface "org.freedesktop.DBus.Properties" doesn't exist#012
modem-manager[483]: <info> (ttyUSB2) serial port closed
modem-manager[483]: <info> Modem /org/freedesktop/ModemManager/Modems/0: state changed (connected -> disconnecting)
modemqemu-kvm-manager[483]: <info> Modem /org/freedesktop/ModemManager/Modems/0: state changed (disconnecting -> connected)
pppd[1369]: Exit.
NetworkManager[431]: <info> disconnect failed: (32) The serial port is not open.
I am afraid, that restarting these USB-daemons on the VM will not be enough - as I will have to tell the qemuKVM-Manager to forward the device once again. But that would be the second step.