Auto-Assign USB port to VM

Post Reply
wilsodg
Know my way around
Posts: 130
Joined: Mon May 20, 2013 12:34 am

Auto-Assign USB port to VM

Post by wilsodg » Sat Nov 29, 2014 7:42 am

TS670 pro, with latest 4.1.1 (nov) release. Running Windows 7 in a VM. Using a USB monitor with an app in the VM Works well for 99% of the time, but I have 2 issues.
First, the VM occasionally (once a week or so) seems to go into suspend mode. Will work on that - could be windows or the NAS.
2nd issue - when I start the NAS or the VM, I have to go in and manually assign the USB device to the VM. is there a way to automate this?

Ideas welcomed please.

wilsodg
Know my way around
Posts: 130
Joined: Mon May 20, 2013 12:34 am

Re: Auto-Assign USB port to VM

Post by wilsodg » Tue Feb 03, 2015 8:31 pm

Bump.
Updated to the 4.1.2 build 20150126 level.
Whilst the VM has stopped going into suspend (think it was a windows power setting), I do still have the issue that the USB port is not assigned to the VM in a definition file - therefore whenever the NAS or the VM are started, I have to go in and re-attach the USB. The VirtualHere USB sharing package seemed to have the ability to pre-assign a USB port to a VM, but (from memory), it was not so stable on the windows side.

So - question.. how to pre-assign a USB port/device to a specific VM. If no simple way to achieve this, how does one ask QNAP to consider adding this function?
Many thanks.

wilsodg
Know my way around
Posts: 130
Joined: Mon May 20, 2013 12:34 am

Re: Auto-Assign USB port to VM

Post by wilsodg » Sun Aug 23, 2015 11:50 pm

Bump again. I have been hoping that QNAP would address the auto-assign of a USB port to a VM when VS is started. It's annoying to have to go in and do this manually. Does anyone know if there a command that can be run within VS or another way to do this?
VS is on 1.4.3901, and QTS is on 4.1.4 2015/05/02 (yes I know it is a bit behind)

arua_chris
New here
Posts: 2
Joined: Tue Apr 21, 2015 10:02 pm

Re: Auto-Assign USB port to VM

Post by arua_chris » Sat Mar 12, 2016 6:28 pm

I would be also interested in such a feature.
I run a kaffeine-instance in a ubuntu-box to record programs from two DVB-S-USB-Devices. Would be nice to restart this one once a day to make sure that it is working in the long run.

arua_chris
New here
Posts: 2
Joined: Tue Apr 21, 2015 10:02 pm

Re: Auto-Assign USB port to VM

Post by arua_chris » Sat Mar 12, 2016 8:15 pm

may be I should have checked it first. Surprisingly it is working.
- Model: TS-453 Pro
- Firmware: 4.2.0 Build 20160130
- Virtualization Station: V2.0.3924
- HD Station: 1.0.0
maybe this helps someone...

christian1302
New here
Posts: 4
Joined: Thu Aug 18, 2016 4:59 am

Re: Auto-Assign USB port to VM

Post by christian1302 » Tue Aug 30, 2016 5:16 am

With mit QNAP TS251+ (Virtualization Station 2.2 Beta) no auto assign of usb is working.
When the device is switched off & on (or awakes from hibernate) the device is listed as externaö device in the qnap web desktop.
I have manually go to virtualization station an reassign the device.

cporeaux
New here
Posts: 6
Joined: Tue Apr 29, 2014 3:24 pm

Re: Auto-Assign USB port to VM

Post by cporeaux » Fri Sep 09, 2016 4:19 pm

Hello,
Same need here (TVS-871), need like you to manually set it up.
Other point : making a cold snapshot remove USB (prompted) but doesn't connect it after snaphost ;-(

about 2 years since first post, maybe someone will read us a day ;-)
NAS #1 (main): TVS-871, RAID5 (4*6Tb WD60EFRX + 1*120Gb SSD Cache Samsung 840 Pro) + 2LAN (r+r) + 1 LAN (VPN)+ 1 LAN (Virtualisation). QTS 4.2.2 (2016/11/02)
NAS #2 : TS-419P+, RAID5 (4*2Tb WD2003FYYS) + 2 LAN (r+r) + eSATA HDD 2Tb. QTS 4.2.2 (2016/11/02)

MassiXV
New here
Posts: 2
Joined: Tue Apr 19, 2016 7:24 pm

Re: Auto-Assign USB port to VM

Post by MassiXV » Fri Oct 14, 2016 1:46 am

Guys, I've opened a ticket and talked with the support requesting if the auto-assignment will ever be implemented and they say they're evaluating the thing! He say they doesn't have an estimated arrival time but definitively they're working on it!

So if you want to see the feature implemented in a reasonable time please submit a ticket (https://helpdesk.qnap.com/index.php?/Tickets/Submit)!
My ticket is yet closed but hopefully with your help we can see this feature live as fast as possible!

Bye guys, and submit!

MassiXV
New here
Posts: 2
Joined: Tue Apr 19, 2016 7:24 pm

Re: Auto-Assign USB port to VM

Post by MassiXV » Fri Dec 23, 2016 6:28 pm

OK, guys this is the guide:

REQUISITES: KNOWING OF SSH, VI, TERMINAL, ENGLISH OR AT LEAST KNOWING HOW TO SEARCH ON GOOGLE

OK, let's go!

1.SSH into the NAS and create a dummy package:

Code: Select all

vi /etc/config/qpkg.conf


Then add at the end of the file:

Code: Select all

[autorun]
Name = autorun
Version = 0.1
Author = Massi-X
Date = 2016-12-12
Shell = /share/MD0_DATA/.qpkg/autorun/autorun.sh
Install_Path = /share/MD0_DATA/.qpkg/autorun
QPKG_File = autorun.qpkg
Enable = TRUE


Create the folder for the package:

Code: Select all

mkdir /share/MD0_DATA/.qpkg/autorun


2.Create the autorun file:

Code: Select all

vi /share/MD0_DATA/.qpkg/autorun/autorun.sh


And put into this:

Code: Select all

#!/bin/sh

# Find where script is located
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# First start and resume windows machine
virsh start Windows
virsh resume Windows

# Wait 10 sec
sleep 10

# Then mount USB 1
virsh attach-device Windows $DIR/Mount_USB_1.xml

# Start windows another time, to be sure
virsh start Windows


Now save and set it executable:

Code: Select all

chmod +x /share/MD0_DATA/.qpkg/autorun/autorun.sh


3.Create the USB info file:

Code: Select all

vi /share/MD0_DATA/.qpkg/autorun/Mount_USB_1.xml


Code: Select all

<hostdev mode='subsystem' type='usb'>
   <source startupPolicy='optional'>
      <vendor id='0x00c3'/>
      <product id='0x0001'/>
   </source>
   <!-- OPTIONAL
       <address type='usb' bus='0' port='5'/>
       -->
</hostdev>


You can find vendor and product ID by issuing lsusb in the terminal.
The address set the port of the guest OS the USB will be connected (WARNING: if the port is in use, the USB will not be connected, remove the comment to using it).

Now save it and exit.

4. DONE!

WARNING: "Windows" is the name of the guest OS, you have to set it accordingly
WARNING: You can repeat the steps 2 ("# Then mount USB 1" and set executable) and 3 to add as many USB devices as you want.

Sources:
viewtopic.php?f=318&t=90425
https://translate.google.it/translate?h ... &sandbox=1
https://access.redhat.com/documentation ... uests.html
https://libvirt.org/formatdomain.html
viewtopic.php?f=16&t=42301
https://wiki.edubuntu.org/VirtFeatureVerification



UPDATE:
After my NAS semi-failed :evil:, I found that sometimes the package run too early, so this is the replacement for point 2 file (with logs too!):

Code: Select all

#!/bin/sh

/sbin/write_log "[WINDOWS AUTOSTART] Starting up Windows Machine" 4

# Find where script is located
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

# Wait until virsh is available

OUTPUT="$(virsh)"

while [[ $OUTPUT == *"command not found"* ]]
do

/sbin/write_log "[WINDOWS AUTOSTART] Virsh command not found, waiting" 4

OUTPUT="$(virsh)"

sleep 10

done

# First start and resume windows machine

virsh start Windows
virsh resume Windows

# Wait 10 sec

sleep 10

# Then mount USB 1
virsh attach-device Windows $DIR/Mount_USB_1.xml

# Start windows another time, to be sure

virsh start Windows

/sbin/write_log "[WINDOWS AUTOSTART] Autostart of Windows Machine Completed" 4

sj44k
Starting out
Posts: 16
Joined: Tue Mar 30, 2010 12:32 am

Re: Auto-Assign USB port to VM

Post by sj44k » Wed Feb 22, 2017 5:11 pm

@MassiXV
I have the same (stupid) issue too, can you do an update about your ticket with support / share the ticket number so I can refer to your ticket when I contact support ?

Just created a ticked ( TFF-174-87798 ) and referred to this topic.
QNAP TS-451, Version 4.3.4, 4x 2TB Raid 5
QNAP TS-410, Version 4.2.6, 3x 2TB 1x 6TB JBOD
Conceptronic CH3SNAS, Running ALT-F Releases / 0.1RC4.1, 2x 1TB

Northpower25
First post
Posts: 1
Joined: Sun Dec 02, 2018 10:32 pm

Re: Auto-Assign USB port to VM

Post by Northpower25 » Sun Dec 02, 2018 10:41 pm

I have the same issue with an Ubuntu VM and an Aeotec USB Stick for Z-Wave home automation. Inside the Ubuntu VW run a Home Assistant Instance that need the Aeotec USB Stick to controll the Z-wave Network. If i take a automatic Snapshot or Backup the stick was lost in the Ubuntu environment and in the Home Assistent Instance until i reboot the Ubuntu VM.

lacalo
First post
Posts: 1
Joined: Tue Oct 15, 2013 5:30 pm

Re: Auto-Assign USB port to VM

Post by lacalo » Tue Dec 25, 2018 3:20 am

I have a virtual machine with Debian 9 on which runs the domotics of Jeedom and that uses two USB devices, one for the zwave network and another RFXCOM for 433 Mhz.
Each time Debian or Virtualization Station is restarted, the network becomes inactive because the USB devices are not reconnected to the virtual machine. It is incredible that Qnap maintains this situation as if it were not their thing. Synology has solved it, but it seems incredible to me that I have to change my installation of NAS for this small matter, which without a doubt produces a great frustration.
I have opened an incident in the support center several months ago, but it seems that they have their resources destined to various nonsense, instead of paying attention to the requests of their users, as justified as this one.

Post Reply

Return to “Virtualization Station”