the hp switch automatically routes because it works also in layer 3?is that right?
Yes, if routing is configured properly.
the only thing i have to do is in my vm the network with vlan 40 to add.
Assuming the physical port is configured as a "tagged" port and VLAN 40 is allowed on it, you may simply create a new port group on the vSwitch and set the VLAN-ID to 40. Then connect the VM's you want to this port group in the VM's settings.
André