Skip to content

Commit

Permalink
Add Blutooth Hci interface down option
Browse files Browse the repository at this point in the history
Everytime before launching android user has to manually
do "sudo hciconfig hci0 down" when BT Card is passthrough.

Added 'bluetooth' section with 'hci_down' flag in the vm-manager.
If set to 'true', will bring down the BT hci interface.

Tests done:
1. Build vm-manager binary
2. Add BT USB Pci address in the [passthrough]
3. Add hci_down=true in [bluetooth]
4. Launch Android and check BT on success
5. Validated on RPL NUC with AX211

Tracked-On: OAM-116593
Signed-off-by: Gowtham Anandha Babu <gowtham.anandha.babu@intel.com>
Signed-off-by: Aman Bhadouria <aman.bhadouria@intel.com>
  • Loading branch information
AmanBh0709 authored and gowthambabu92 committed May 7, 2024
1 parent 943994a commit 1f0b028
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/fields.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,6 @@ Requirements
- cmd: Set extra command.
- service: Set extra services, use `:` split different services.
- pwr_ctrl_multios: If set to "true", will create qmp socket in /tmp/ folder for suspend/hibernate feature. Setting to "false" will not create the sockeet.

### [bluetooth]
- hci_down: If set to 'true', will bring down Bluetooth Hci Interface. Make sure BT USB Pci address is added in `[passthrough]`.
1 change: 1 addition & 0 deletions src/guest/config_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ map<string_view, vector<string_view>> kConfigMap = {
{ kGroupRpmb, { kRpmbBinPath, kRpmbDataDir } },
{ kGroupAaf, { kAafPath, kAafSuspend, kAafAudioType }},
{ kGroupPciPt, { kPciPtDev }},
{ kGroupbluetooth, { kHciDown }},
{ kGroupAudio, { kDisableEmul } },
{ kGroupMed, { kMedBattery, kMedThermal, kMedCamera } },
{ kGroupService, { kServTimeKeep, kServPmCtrl, kServVinput } },
Expand Down
3 changes: 3 additions & 0 deletions src/guest/config_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ constexpr char kGroupVtpm[] = "vtpm";
constexpr char kGroupRpmb[] = "rpmb";
constexpr char kGroupAaf[] = "aaf";
constexpr char kGroupPciPt[] = "passthrough";
constexpr char kGroupbluetooth[] = "bluetooth";
constexpr char kGroupAudio[] = "audio";
constexpr char kGroupMed[] = "mediation";
constexpr char kGroupService[] = "guest_control";
Expand Down Expand Up @@ -78,6 +79,8 @@ constexpr char kAafAudioType[] = "audio_type";

constexpr char kPciPtDev[] = "passthrough_pci";

constexpr char kHciDown[] = "hci_down";

constexpr char kDisableEmul[] = "disable_emulation";

constexpr char kMedBattery[] = "battery_med";
Expand Down
13 changes: 13 additions & 0 deletions src/guest/vm_builder_qemu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,18 @@ bool VmBuilderQemu::SetupSriov(void) {
return true;
}

void VmBuilderQemu::BringDownBtHciIntf() {
std::string hci_status = cfg_.GetValue(kGroupbluetooth, kHciDown);
boost::trim(hci_status);
if (hci_status == "true") {
LOG(info) << "Shutting down Hci Interface!!!\n";
int result = boost::process::system("sudo hciconfig hci0 down");
if (result != 0) {
LOG(warning) << "Failed to execute command: sudo hciconfig hci0 down";
}
}
}

void VmBuilderQemu::BuildExtraGuestPmCtrlCmd(void) {
std::string ex_cmd = cfg_.GetValue(kGroupExtra, kExtraPwrCtrlMultiOS);
if (ex_cmd == "true") {
Expand Down Expand Up @@ -413,6 +425,7 @@ void VmBuilderQemu::BuildPtPciDevicesCmd(void) {
std::vector<std::string> vec;
boost::split(vec, pt_pci, boost::is_any_of(","), boost::token_compress_on);

BringDownBtHciIntf(); // Bring down blutooth hci interface before passthrough
for (auto it=vec.begin(); it != vec.end(); ++it) {
boost::trim(*it);
if (PassthroughOnePciDev(it->c_str(), kPciPassthrough)) {
Expand Down
1 change: 1 addition & 0 deletions src/guest/vm_builder_qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class VmBuilderQemu : public VmBuilder {
void BuildVcpuCmd(void);
bool BuildFirmwareCmd(void);
void BuildVdiskCmd(void);
void BringDownBtHciIntf();
void BuildPtPciDevicesCmd(void);
void BuildGuestTimeKeepCmd(void);
void BuildGuestPmCtrlCmd(void);
Expand Down

0 comments on commit 1f0b028

Please sign in to comment.